Saturday, November 11, 2006

Google Maps API Update

Well, I got bitten by the Google Maps API update that happened on Wednesday. The code for my Photo Gallery Map used several conventions that were rendered obsolete. So, I employed my not-so-mad programming skills, looked at the API Reference, and managed to "H4X0R" my map back into operational status.

The good news -- it works again, and I'll be OK until API version 2 is made obsolete at some undisclosed future date. The other good news, there was an upgrade cheat-sheet that made my life easier.

What did I have to change in my simple page code:
In addition to the trivial required change from GMap to GMap2, GPoint now refers to a location on the bitmap, and not a geographical location. I was using it "the old way." A new GLatLng class was introduced to reference geographical points. This new version also swaps the position of the Latitude and Longitude data with respect to the old convention (Gee, imagine that Lat/Long specified in that order...). So, all references that used to look like this:
new GPoint(-115.173019, 36.095472)
now look like this, instead:
new GLatLng(36.095472,-115.173019)

Also, the zoom factor got reversed, so my old zoom factor of 13 is now a zoom factor of 4 to display the same view (it's more intuitive now, bigger number=more zoom).

Finally, the "Map Type" convention changed. What used to be _HYBRID_TYPE is now known as G_HYBRID_MAP... This was also made easier, as setCenterAndZoom and setMapType have been combined into a single setCenter operation.