Radius based search with Leaflet maps

2,350 views
Skip to first unread message

shaist...@gmail.com

unread,
Jul 3, 2014, 4:30:56 AM7/3/14
to leafl...@googlegroups.com

Using leaflet I have created a simple map, played around with markers (adding/removing) and have added some GeoJSON data polygons etc. I now need help with implementing a radius search. For example I want to restrict the markers placed on the map by radius/distance in metres/cm etc. I want to achieve this in two ways. example:

  1. The user will enter a distance in metres and click submit. This should only bring the markers back within that distance/radius. My markers are populated using Lat/Long coords. Is this possible to achieve what i want or do i need additional data along with Lat/Long.

  2. The user should be able to drag a marker on the map and click submit which should return all the markers within 300 metres of the marker.

Is the above possible with leaflet and can anyone point me to any plugins which can achieve the above.

k_man_au

unread,
Aug 1, 2014, 2:24:47 AM8/1/14
to leafl...@googlegroups.com
This question came up before... answer as was last time, was that Leaflet does not have a built in buffer function so you'd have to roll your own with something like the following

Get your search distance (in this case circle of 100m radius)

- Capture clicked point 
- Generate bounding box adding (say) 100m to each side of point.
- Iterate through JSON selecting points within bounding box
- Check each point distance to selected point via Haversine formula (only necessary if the selection needs to be a perfect circle of 200m diameter)
- Move point to results set

Would need to keep performance a careful consideration. For a handful of points it would be ok... anything more then look at doing it server side... If the buffer only needs to be approx skip the haversine check and buy some cpu cycles :)

Marcos Eichemberger Ummus

unread,
Aug 1, 2014, 8:21:28 AM8/1/14
to leafl...@googlegroups.com

Kiran Patil

unread,
Dec 13, 2017, 7:59:39 AM12/13/17
to Leaflet
Hi,

I would like to get list of markers as cluster1, cluster2 and ...

Cluster radius is 2meter.

Did you find any solution ?

Any approach you taken so far to resolve it ?

Regards,
Kiran.
Reply all
Reply to author
Forward
0 new messages