And frankly, even if you don’t have 89 locations, it really is kinda of silly to constantly ask Google for address data for locations that aren’t moving around. He asked if I could modify the code a bit to use long/lat data and I was glad to oblige.
(As a quick aside: In my sample data you will see long/lat pairs along with static locations. The long/lat pairs may not match the actual addresses. I asked him for sample data and simply meshed it with my static list of four locations.)
Let’s take a look. The first thing I did was add the long/lat as data in my static array:
Note that I’m keeping the address. That’s used in the markers since most humans can’t translate a longitude/latitude pair to a physical location. (Hell, I can’t even remember which is which most of the time.)
The next change was simple - I just got rid of the geocoder call and its callback wrapper. In this code block you can see where I’m simply looping over the data and and using the static location in the marker.position value.
And that’s it. You can run this version by hitting the demo link below. It probably isn’t that terribly faster in your desktop browser, but on a mobile device the savings would be much more important.