简体   繁体   English

Google Maps Marker丛集

[英]Google Maps Marker Cluster

Hi I am trying to add clustering to my google map. 嗨,我正在尝试将群集添加到我的谷歌地图。 Its been about eight years since I've actually programmed anything so I've reverted to modifying another website due to my lack of knowledge. 自从我实际编写任何程序以来已经有大约八年的时间了,由于我缺乏知识,我已恢复修改另一个网站。 I have added the maerkerclusterer.js script to my page, but I have not idea where to parse 我已经在页面中添加了maerkerclusterer.js脚本,但是我不知道在哪里解析

var markerCluster = new MarkerClusterer(map, markers);

though the marker array. 通过标记数组。 A demo of my code can be found below: 我的代码的演示可以在下面找到:

Google Map 谷歌地图

Line 115 should be : 第115行应为:

var len = guests.length;
var markerArray = [];

Than, lines 141-142 to: 比第141-142行要:

var marker = google.maps.Marker(map, guests[i]);
markerArray.push(marker );

      } 
var markerCluster = new MarkerClusterer(map, markerArray);

This should get it to work. 这应该使其工作。

The point of the chnge is to sen the MarkerClusterer an array that contains only the markers, nothing else as the core code is other wise confused and throwing errors. 该chnge的一点是森MarkerClusterer只包含标记,闲来无事为核心代码是其他明智的困惑和投掷错误的数组。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM