How can I cluster markers without overlap with google maps?

不问归期 提交于 2019-11-28 09:42:17

问题


I am currently clustering hundreds of markers on my google maps. Many of the markers are based on geo-coded addresses, which at times only resolve to the city level. Normally i will end up with lets say a few hundred addresses all with the same lat lon for example in the middle of New York City.

I know about the Marker Clustering in google maps, however when all the markers have the same lat long, you loose the ability to click on each marker, and bring up a popup.

How can I manage these markers in such a way when you zoom in you can still tell how many markers there are, and still click on them?


回答1:


Look at the OverlappingMarkerSpiderfier

See this post on integrating it with MarkerClusterer




回答2:


I had a similar (albeit not exactly the same) problem.

I needed to draw sample points in a plot chart. But I found collisions (exact overlap for some points coming from coarser lectures) and aliasing artifacts (partial overlaps with repeating some fixed amount of displacement due also to coarser lectures).

I decided to introduce some random displacements to all of the points. The "noise" had a normal distribution with a variance two times smaller than the variance of the measured error of the sample, so it did not change add significant variance to the perceived sample. The result was a much clearer chart, more informative, and nicer.

Applying this experience in your case, I would detect exact overlaps in Lat Long and for those I would add some random Lat and Long, effectively moving the point a bit away of its original position and thus avoiding the exact overlap.



来源:https://stackoverflow.com/questions/11781183/how-can-i-cluster-markers-without-overlap-with-google-maps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!