繁体   English   中英

懒惰/需求在Google地图或Google Earth插件中加载KML?

[英]lazy / demand load KML in google maps or google earth plugin?

启动Google Map或Google Earth Plugin实例后,是否可以延迟加载KML文件? 也许有一个“边界框”事件可以用来排队所需的KML文件?

编辑=>找到答案:

找到了这个小窍门( http://code.google.com/apis/maps/documentation/javascript/events.html ):

注意:如果您尝试检测视口中的更改,请确保使用特定的bounds_changed事件,而不是使用zoom_changed和center_changed事件。 由于Maps API会独立触发后面的这些事件,因此,除非对视口进行了权威性更改,否则getBounds()可能不会报告有用的结果。 如果您希望在此类事件之后获取getBounds(),请确保改为监听bounds_changed事件。

...导致我在此页面上进行“视口标记管理”: 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 Earth Plugin或Google Maps Apis中使用KML,则无需自己做饭...

有关使用Kml区域的信息,请参见以下出色的文档: http : //code.google.com/apis/kml/documentation/regions.html

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

暂无
暂无

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

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