这是我的 Google 地图“设置”
- 我从数据库中读取了所有标记的位置(低于 300) - 将它们作为 Json 发送到 javascript
- 在 javascript 上,我解析 json,查看标记数组并创建一个新的 google.maps.Marker。对于每个标记,我添加一个 clicl 事件,它将打开一个包含主图片和一些自定义详细信息的信息框(infoBox.js)。之后我创建集群(使用 MarkerClusterer)并且一切正常(至少对于 3-400 个标记)
我想扩展并显示最多 10k 个标记(使用 MarkerClusterer)。最好的方法是什么?
我正在考虑将所有标记数据写入一个文件(作为 javascript 数组或 xml),并从那里读取 javascript,因为在数据库中查询 10k 个位置是不切实际的。你有其他建议吗?
我应该使用相同的循环槽数组并一次放置一个标记吗?
我查看了 kml 图层,但似乎我无法导航槽标记(我有上一个/下一个位置功能)并且我可能无法使用 infobox.js ?
有什么建议吗?
正如 @geocodezip 提到的,请查看该文档,而不是查看 Cluster 解决方案,请查看视口标记管理 https://developers.google.com/maps/articles/toomanymarkers#viewportmarkermanagement部分。
如果您的数据库支持地理空间查询,您可以请求在地图发布后仅返回给定范围内的标记。idle
.
google.maps.event.addListener(map, 'idle', function(){
var bounds = map.getBounds(); //returns an object with the NorthEast and SouthWest LatLng points of the bounds
//make the AJAX request passing in your `bounds`
/*in the AJAX callback remove the current markers from the map and the cluster object,
and add the new ones along with their event handlers and re-add to the cluster object as well*/
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)