We use leafletJS to show maps with round about 100 markers. Some of these markers are located on exact the same position. Marker2 is above Marker1 so Marker1 isn't visible. Is there a way to rotate Markers in a way that you can see there are more then one marker?
相关问题
- Leaflet popups for specific base maps
- leafletjs adding scrollable pop up?
- Add text inside leaflet rectangle
- Fit map to bounds exactly
- Popup on hovering over cluster group
相关文章
- change leaflet marker icon
- Prevent zooming out in leaflet R-Map?
- Multiple markers on the exact same position on a L
- leaflet how to make dynamic picture popup using js
- Fill polygon with pattern doesn't work with le
- Leaflet: how to swap coordinates received from an
- Add polygon to map R leaflet
- Leaflet map returns to its original configuration
may be you should look at https://github.com/Leaflet/Leaflet.markercluster plugin here demo - http://leaflet.github.io/Leaflet.markercluster/example/marker-clustering-realworld.388.html
The drawback with walla's answer is that Leaflet.markercluster requires clustering, which may not be an option depending on your requirements i.e. you need to always display individual markers.
OverlappingMarkerSpiderfier-Leaflet (a bit of a mouthful) works well in this case and it's fairly well documented. It displays a 'spider' of markers on click only if they overlap i.e. if the zoom level increases so markers don't overlap, then it won't 'spider' on click, which is quite nice. Demo.
It's available as a NPM package but it isn't a proper ES module, so usage is a bit trickier than usual if you're expecting an ES module:
Alternatively there is a forked version (confusingly) called OverlappingMarkerSpiderfier that is a proper ES module so you can do:
However there's a fair bit of divergence based on commits between the two so YMMV.
FWIW I'm using the original.
we had the same problem, follows the jsFiddle with the solution we found http://jsfiddle.net/atma_tecnologia/mgkuq0gf/2/