KML图层渲染顺序Google地图 [英] KML Layers rendering order google maps

查看:224
本文介绍了KML图层渲染顺序Google地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到以下APIS有一些不同的行为

I have noticed some different behavior with the following APIS

<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>

http://jsfiddle.net/x8dSP/2062/

有时多边形层会在气球层的顶部渲染,有时会相反.

Sometimes the polygon layer renders ontop of the balloon layer, and sometimes the opposite.

好像在地图被缓存"之后?在浏览器中,它将以多边形层位于顶部的方式进行渲染.反正有防止这种情况发生的方法吗?还是让一层始终在背景中?不幸的是,我无法在一个kml中映射这些图层.

It seems like after the map is "cached?" in the browser it will render with the polygon layer ontop. Is there anyway to prevent this? Or to have one layer always be in the background? Unfortunately I cannot map these layers in one kml.

推荐答案

将按照从服务器接收的顺序渲染图层(不一定是它们在代码中出现的顺序).您可以通过在设置第二个地图的map属性之前等待KmlLayer status_changed事件来强制另一个载入.

The layers get rendered in the order they are received from the server (which is not necessarily the order in which they appear in the code). You can force one to load after the other by waiting for the KmlLayer status_changed event before setting the map property of the second.

function initialize() {
  var chicago = new google.maps.LatLng(-122.365662,37.826988);
  var mapOptions = {
    zoom: 11,
    center: chicago
  }

  var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);

  var ctaLayer = new google.maps.KmlLayer({
    url: 'https://sites.google.com/site/gmaptest123/kml/nst.kml'
  });
  google.maps.event.addListener(ctaLayer, "status_changed", function() {
    ctaLayer2.setMap(map);
  });
  ctaLayer.setMap(map);

  var ctaLayer2 = new google.maps.KmlLayer({
    url: 'https://sites.google.com/site/gmaptest123/kml/HelloKml6.kml'
  });
}
google.maps.event.addDomListener(window, 'load', initialize);

更新了小提琴

这篇关于KML图层渲染顺序Google地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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