Google Maps API Tutorial

Associative arrays and Custom Icons

When I want to manage custom icons with information from XML data, I like to use an associative array.

Javascipt associative arrays can be used just like ordinary arrays, except that they use a string instead of a number
as the index.

This means that you can store a meaningful name for the icon type in the XML data, rather than a meaningless number,
without having to have a string of if statements to translate the XML attribute into the corresponding GIcon variable name.

E.g. if you've got custom icons that represent a house, a school and a factory, you can create an array like this