An Unfortunate Truth
Sitting on a third floor table of Allen Hall (the journalism and communication school) at the University of Oregon my my colleagues pass by asking “mapping?” I sight and respond with a smile “nothing but.”
The reason for this sigh has revealed itself as a disappointing yet without persuasion truth. FireFox is indeed not the browsers best friend.
For several weeks I could not figure out why only Firefox would plot addresses from an XML file on a Google map in the same order each time. Safari and IE would plot points in an order arbitrary to the order of the XML file. Well the reason that FireFox was the only one that worked properly was because it is in fact the slowest browser.
Here’s the lowdown: To plot addresses on a Google map they need to be geocoded. Google needs latitude and longitude to plot a point on a map. well here lies the problem. Google takes time to respond to the geocode request. So if the code doesn’t have patience and goes right on plotting before the response things will get out of order because the plotting and receiving of the latitude and longitude and not synchronized.
So because FireFox took its sweet time to execute the code Google had time to respond whereas Safari and IE whizzed through the code before Google had time to fully respond.
Here’s the Solution: Use setInterval to delay to the code a bit while Google is responding. I will give you a bit more of my code, but not too much that you will find out exactly what i am doing before official release.
var address = addresses[i];
var nextAddress = (res.length-1);
window.theNext = function() {
if (nextAddress < addresses.length) {
setTimeout(’getAddress(”‘+addresses[nextAddress]+’”,theNext)’, 50);
nextAddress–;
}
}