在谷歌地图或谷歌地球插件中惰性/需求加载KML?

2024-01-27

一旦 Google 地图或 Google 地球插件实例启动,是否可以延迟加载 KML 文件?也许有一个“边界框”事件,我可以用它来排队所需的 KML 文件?

编辑=>找到答案:

发现了这个小花絮(http://code.google.com/apis/maps/documentation/javascript/events.html http://code.google.com/apis/maps/documentation/javascript/events.html ):

注意:如果您尝试检测 改变视口,一定要使用 特定的bounds_changed事件 而不是组成部分zoom_changed 和 center_changed 事件。因为 地图 API 会触发后面这些事件 独立地, getBounds() 可能不会 报告有用的结果,直到 视口已发生权威性更改。 如果你想在这样之后 getBounds() 一个事件,一定要听 相反,bounds_changed 事件。

...这使我进入此页面上的“视口标记管理”:http://code.google.com/apis/maps/articles/tooomymarkers.html#viewportmarkermanagement http://code.google.com/apis/maps/articles/toomanymarkers.html#viewportmarkermanagement

建议这个基本想法:

  google.maps.event.addLisener(map, 'idle', showMarkers);

  function showMarkers() {
    var bounds = map.getBounds();

    // Call you server with ajax passing it the bounds

    // In the ajax callback delete the current markers and add new markers
  }

同样,对于GEP,有这样的:

GEView.getViewportGlobeBounds()
返回一个完全的边界框 包含地球上的区域 目前可见。退回的盒子 会比严格意义上的要大 可见,如果有必要的话 包括一切可见的东西。

返回一个对应的KmlLatLonBox 到当前的边界框 视口或 null 如果没有部分 地球仪可见


是的,KML 区域仅当数据位于用户视图内并占据屏幕的特定部分时才允许加载和绘制数据。因此,如果您在 Google 地球插件或 Google 地图 API 中使用 KML,则无需自己烹饪...

请参阅这个有关使用 Kml 区域的精彩文档:http://code.google.com/apis/kml/documentation/regions.html http://code.google.com/apis/kml/documentation/regions.html

连同 kmlRegion 接口参考http://code.google.com/apis/kml/documentation/kmlreference.html#region http://code.google.com/apis/kml/documentation/kmlreference.html#region

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在谷歌地图或谷歌地球插件中惰性/需求加载KML? 的相关文章