Francesco Addis
Francesco Addis

Reputation: 11

Load two or more kml files using API V3

How can I load two or more kml files using API V3?

In this way it works,

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

but if I want to load two or more maps, what I should do?

Upvotes: 1

Views: 255

Answers (1)

JuanDeLosMuertos
JuanDeLosMuertos

Reputation: 4620

Looking at the google maps api documentation, you should try something like this:

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

Upvotes: 1

Related Questions