【问题标题】:Best solution for too many pins on google maps谷歌地图上太多引脚的最佳解决方案
【发布时间】:2013-12-06 18:36:22
【问题描述】:

这是我的 Google 地图“设置”

  • 我从数据库中读取了所有标记的位置(低于 300) - 将这些标记作为 Json 发送到 javascript
  • 在 javascript 上,我解析 json,查看低谷标记数组并创建一个新的 google.maps.Marker。对于每个标记,我为 clicl 添加一个事件,该事件将打开一个带有主图片和一些自定义详细信息的信息框 (infoBox.js)。之后,我创建了集群(使用 MarkerClusterer)并且一切正常(至少对于 3-400 个标记)

我想扩展并显示多达 10k 个标记(使用 MarkerClusterer)。最好的方法是什么?

我正在考虑将所有标记数据写入文件(作为 javascript 数组或 xml)并从那里读取 javascript,因为在数据库中查询 10k 个位置是不切实际的。你有其他建议吗?

我应该使用相同的循环槽数组并一次放置一个标记吗? 我查看了 kml 图层,但似乎无法导航槽标记(我有上一个/下一个位置功能),我可能无法使用 infobox.js?

有什么建议吗?

【问题讨论】:

标签: javascript google-maps google-maps-api-3


【解决方案1】:

正如@geocodezip 提到的,请查看该文档,而不是查看集群解决方案,请查看Viewport Marker Management 部分。

如果您的数据库支持地理空间查询,一旦地图为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*/

});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-12
    • 1970-01-01
    • 1970-01-01
    • 2011-01-20
    • 2020-08-11
    • 2023-03-13
    相关资源
    最近更新 更多