Chris Essig

Walkthroughs, tips and tricks from a data journalist in eastern Iowa

Leaflet formula: Counting markers within a radius (version 2)

with 2 comments

A couple of years ago, I open-sourced a project that allows you to count how many markers are within a circle using Leaflet. As part of the template, a user needs to enter an address to get a marker to show up on the map.

Two weeks ago, Jefferson Guerrón reached out to me because he was creating something similar that didn’t require a user to type in their address. He was using the plugin Leaflet.draw to get the marker on the map. But he was having a hard time getting a circle to show up around the marker and count the other markers within that circle.

After a few back-and-forth emails, we were able to come up with a solution. Here’s a look of the final project. And the code is available on Github.

If you have questions, don’t hesitate to e-mail or comment.

Advertisements

Written by csessig

December 14, 2016 at 5:15 pm

2 Responses

Subscribe to comments with RSS.

  1. Hello,
    I would like to use part of the code on a project Im working on.
    Unfortunately Im really new to Json. Where would I use my JS to get the markers within the radius to be listed in a textbox next to the map?
    Would really really appreciate the help.

    Thanks

    Werner Swart

    May 17, 2017 at 2:07 am

    • Hi Werner,

      Do you have a project started? And if so, what do you have so far?

      csessig

      May 17, 2017 at 3:06 pm


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: