懒惰/需求在Google地图或Google Earth插件中加载KML? [英] lazy / demand load KML in google maps or google earth plugin?

查看:132
本文介绍了懒惰/需求在Google地图或Google Earth插件中加载KML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Is it possible to lazy load KML files once a Google Map or Google Earth Plugin instance is started? Maybe there is there a "bounding box" event that I can use to queue needed KML files?

编辑=>找到答案:

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

Found this little tid-bit ( http://code.google.com/apis/maps/documentation/javascript/events.html ):

注意:如果您尝试检测到 更改视口,请务必使用 具体的bounds_changed事件 而不是成分zoom_changed 和center_changed事件.因为 Maps API会触发这些后期事件 独立地,getBounds()可能不会 报告有用的结果,直到 视口已经进行了权威性的更改. 如果您希望在此类之后获取getBounds() 一个事件,一定要听 而是使用bounds_changed事件.

Note: If you are trying to detect a change in the viewport, be sure to use the specific bounds_changed event rather than constituent zoom_changed and center_changed events. Because the Maps API fires these latter events independently, getBounds() may not report useful results until after the viewport has authoritatively changed. If you wish to getBounds() after such an event, be sure to listen to the bounds_changed event instead.

...导致我在此页面上进行视口标记管理":

...which led me to "Viewport Marker Management" on this page: 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,是这样的:

Similarly, for GEP, there is this:

GEView.getViewportGlobeBounds()
返回一个完全完整的边界框 包含全球范围内的 当前可见.退回的盒子 将大于严格 可见,如果有必要 包括所有可见的东西.

GEView.getViewportGlobeBounds()
Returns a bounding box that completely contains the region of the globe that is currently visible. The returned box will be larger than what is strictly visible, if that is necessary to include everything that is visible.

返回一个KmlLatLonBox对应的 到当前的边界框 视口;如果没有视口,则为null 地球是可见的

Returns a KmlLatLonBox corresponding to the bounding box of the current viewport or null if no part of the globe is visible

推荐答案

是的,KML区域仅允许数据落入用户视图并占据屏幕的特定部分时才允许加载和绘制数据.因此,如果您在Google Earth Plugin或Google Maps Apis中使用KML,则无需自己动手做饭.

Yes, KML regions allow data to be loaded and drawn only when it falls within the user's view and occupies a certain portion of the screen. So there is no need to cook your own if you are using KML in the Google Earth Plugin or Google Maps Apis...

有关使用Kml区域的详细信息,请参见: http://code.google.com/apis/kml/documentation/regions.html

See this great document on using Kml regions: http://code.google.com/apis/kml/documentation/regions.html

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

Along with the kmlRegion interface reference http://code.google.com/apis/kml/documentation/kmlreference.html#region

这篇关于懒惰/需求在Google地图或Google Earth插件中加载KML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆