make groups for markers in google map apiV3

梦想的初衷 提交于 2019-12-08 10:25:16

问题


I found a very good tutorial which put the markers from any IP address. (google maps) http://lab.abhinayrathore.com/ipmapper/

I would like to modify this code: http://lab.abhinayrathore.com/ipmapper/ipmapper.htm . I have more than 500 markers in the same area, and I would like to make groups, something like this: http://google-maps-utility-library-v3.googlecode.com/svn/tags/markerclustererplus/2.0.9/examples/simple_example.html

So I modified the original code I put the 37. Line this code:

var markerCluster = new MarkerClusterer(IPMapper.map, ipArray); 

I think this line make the groups, but nothing happened.

Can anybody help me what do I wrong?


回答1:


You'll need to instantiate an array just before you start calling addIpMarker.

Remove line 57 and instead create a new Google maps marker, it's called in a loop so it will create a new marker for each ip.

Push this marker to the array you initially created so that when the loop ends you have an array of markers.

Then call: var markerCluster = new MarkerClusterer(yourMap, yourNewArray).

Previously you were passing the array of ip addresses to the marker cluster rather than an array of markers, while the addIPMarker function was adding them independently to the map.

Hope this helps.

PasteBin: http://pastebin.com/0fteg7g1 to fix.



来源:https://stackoverflow.com/questions/16057252/make-groups-for-markers-in-google-map-apiv3

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