[incise.org] very simple google maps hack

A while back I made a world map for INTP Central using Google maps, and it took me some time to get it all figured out in my head. So I hope I can clear up some things for people wanting to do something similar.

First off, you can't easily turn an address into lat/long via google maps, at least not yet. There was something I recall seeing that did it, but it was a Python script you had to run and it generated some XML and it just seemed like a big pain in the ass to automate in any way. But there are other sites which will turn zip codes or city names into lat/long for you. A couple examples are zipinfo and Heavens Above. You could fairly easily automate something that used these. If you want more precise positioning (like by street address), I'm not sure what your options are.

But I just decided to let people manually look that up themselves. We added lat/long fields to the profile database for the forum, and forum users would enter the lat/long into their forum profile. Then they would automatically show up on the map. On the client side, the Javascript reads from an array containing names, lat, and long. It then maps them and uses the people's names as the labels. To generate the Javascript array, a little mysql query is run and the result is formatted by some PHP into Javascript array syntax. It's then inserted in the appropriate place in the rest of the Javascript.

Check out the actual code here. (Currently not displaying due to google API key BS. Put it on your own site and use your key and it should work properly.) If you have any suggestions or feedback, please feel free to contact me at mack (@) incise.org.


Nick Welch <nick@incise.org>