1

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

以这种方式工作,

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

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

4

1 回答 1

1

查看google maps api 文档,您应该尝试以下操作:

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

于 2013-10-17T08:22:28.880 回答