在Google Map apiV3中对标记进行分组 [英] make groups for markers in google map apiV3

查看:128
本文介绍了在Google Map apiV3中对标记进行分组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找到了一个很好的教程,该教程可以放置来自任何IP地址的标记. (谷歌地图) http://lab.abhinayrathore.com/ipmapper/

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

我想修改以下代码: http://lab.abhinayrathore.com/ipmapper/ipmapper.htm .我在同一区域有500多个标记,我想进行分组,如下所示: http://google -maps-utility-library-v3.googlecode.com/svn/tags/markerclustererplus/2.0.9/examples/simple_example.html

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

因此,我修改了放入37的原始代码.将此代码行:

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?

推荐答案

您需要在开始调用addIpMarker之前实例化一个数组.

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

删除第57行,而是创建一个新的Google Maps标记,该标记在循环中被调用,因此它将为每个ip创建一个新的标记.

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.

然后调用:var markerCluster = new MarkerClusterer(yourMap,yourNewArray).

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

以前,您是将IP地址数组传递给标记群集,而不是传递标记数组,而addIPMarker函数将它们独立地添加到映射中.

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.

希望这会有所帮助.

PasteBin: http://pastebin.com/0fteg7g1 进行修复.

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

这篇关于在Google Map apiV3中对标记进行分组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆