I am using the following extract of code to show markers on my map, with the custom marker colour determined by the category which it falls within.
var customIcons = {
Artefact: {
icon: 'http://labs.google.com/ridefinder/images/mm_20_red.png',
shadow: 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'
},
Coin: {
icon: 'http://labs.google.com/ridefinder/images/mm_20_green.png',
shadow: 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'
},
Jewellery: {
icon: 'http://labs.google.com/ridefinder/images/mm_20_yellow.png',
shadow: 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'
},
Prescious Metal: {
icon: 'http://labs.google.com/ridefinder/images/mm_20_blue.png',
shadow: 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'
}
};
The problem I’m having is with the last category, ‘Prescious Metal’. For the life of me I can’t get the script to work when there is a space between the words. I’ve tried adding ‘ ‘ which I thought may be a work around this, but it still doesn’t work.
Keys in JavaScript object literals must follow the variable naming convention, or be strings. Putting quotes around it fixes the issue.