问题描述
|
启动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