使用API​​ V3加载两个或更多kml文件

时间:2013-10-17 07:52:27

标签: google-maps-api-3 kml

如何使用API​​ V3加载两个或更多kml文件?

这样就可以了,

new google.maps.KmlLayer(    'http://www.example.com/kml/map.kml?&rand='+(new Date())。valueOf(),{    preserveViewport:true,    地图:地图 });

但如果我想加载两张或更多张地图,我该怎么做?

1 个答案:

答案 0 :(得分:1)

查看google maps api documentation,你应该尝试这样的事情:

var kmllist = ["path1.kml", "path2.kml", ... ];
var kmllayers = [];
for kmlurl in kmllist: 
for (var i = 0; i < kmllist.length(); i++) 
{
  var lay = new google.maps.kmllayer(opts); 
  lay.setUrl(kmllist[i]);
  lay.setMap(map);
  kmllayers.push(lay);
}

opts = kmlLayerOptions