I had a bit of a "derrr" moment, today. When trying to set custom zoom
levels for markers (the value of which I pulled from an XML PHP MySQL
readout), I was trying to do this:

var zoomLevel = markers[i].getAttribute("zoomLevel");
map.setCenter(latlng, zoomLevel);

Much to my dismay, it was definitely not working. Replacing the
reference to zoomLevel like so:

map.setCenter(latlng, 13);

worked quite without fail.

After five minutes of head scratching, I remembered something I
learned when working with javascript last time. It tends to treat,
what would appear to be integers, as strings.

In order to make it work, I had to first perform a mathematical
operation on the string, to force javascript to recognise it as an
integer:

var zoomLevel = markers[i].getAttribute("zoomLevel");
zoomLevel = zoomLevel / 1;
map.setCenter(latlng, zoomLevel);

Just in case any other javascript noobs stumble across that little
annoyance.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to