I'm teaching myself javascript by creating my wedding website using the google maps API. I've figured out a lot through the docs and copypasta experimentation, but don't know how to make this happen: what I want to do is read an external XML file containing icon information (names and offsets for a sprite image containing the icons), and store it in an array that I can access when creating map markers. For example, I want to be able to create a marker for the reception and assign it the icon "party". Here's the code I have so far for reading the icon file:
jQuery.get("markericons.xml", {}, function(data) {
jQuery(data).find("markericon").each(function() {
var icon = jQuery(this);
var name = icon.attr("name");
var url = 'images/icons/mapsprites.png';
var size = new google.maps.Size(32, 37);
var origin = new google.maps.Point(parseInt(icon.attr("x")),parseInt(icon.attr("y")));
var anchor = new google.maps.Point((origin.x+16),origin.y);
var icon = new google.maps.MarkerImage(url, size, origin, anchor);
});
}); // how to store this in an array so that I can access elements by name later?
And then, when creating the actual placemarks on the google map, something like the following:
var marker = new google.maps.Marker({
position: latlng,
map: map,
icon: icon.name=="party", // pseudo-code... how to do this?
title: title
});
I'm still a programming noob, so I'd appreciate any help. Thanks!