We can learn how to customize the marker icon for a kml file parsed using geoxml3 (from the answer to this question on SO)).
Code:
var myparser = new geoXML3.parser({
map: map,
markerOptions: {
icon: "http://maps.google.com/mapfiles/ms/micons/blue.png"
}
});
However, I’d like to make my code more efficient when parsing multiple kml files by passing an array of kml URLs to the geoxml3 parser. Here's an example of using an array of kml files and one call to the parser:
var urlArray =[];
urlArray.push("pathto/data1.xml");
urlArray.push("pathto/data2.xml");
var myParser = new geoXML3.parser({
map: map,
processStyles: true,
zoom:false,
markerOptions: {
icon: {
url: "pathTo/icon.png", // url
scaledSize: new google.maps.Size(48, 48) // scaled size
}
},
afterParse: useTheData
});
myParser.parse(urlArray);
}
This will set all the options for each kml file parsed to be the same. Questions:
(1) Using the geoxml3 parser this way will create a docs[] array such that I can access each kml file's parsed results using myParser.docs[0] and myParser.docs[1], correct? This is the 'efficiency' I'm looking for.
(2) How can I uniquely set the marker icon for each kml file parsed to a different unique icon with different attributes such as size?
Create a new instance of the GeoXml3 parser for each file, specify the desired marker icon in the constructor.
The icon used for the file is defined in the array below. Since you need to create a new instance of the parser to change the icon you can't pass an array of URLs to the parser and change the icon per URL in that array.
code snippet (with reduced KML due to post size constraints):