A strange tale of knowledge
I never expected anything positive to come out of the past 4 days spent struggling with Google's V2 map API, trying to fix a broken piece of code from V1, only to find (not on Google's site) that the cause was the removal of a little piece of code from one of the functions.
Today, I found some kind soul had added a recipe to the bolt-on options of my favourite wiki code, and it embeds a Google map into a page. It was marked stable and API V2 compliant – little did I know that dropping this in was going to use all I'd learnt in the past 4 days…
API V2 compliance? Wellllllll…
- Used GMap instead of GMap2
- Used Gpoint instead of GLatLng
- Used centerAndZoom instead of setCenter
- The configuration file had a line with no value assigned to a variable, and no semicolon at the line end, so it aborted the script when attempting to load the web site.
- The value was just left blank, instead of being set to " ".
- The API key was referred to as a Cert in the config file, so it wasn't passed to Google's server when the map tried to load. No map.
- The API key wasn't set in the config file, so the script had nothing to build the access key with to access Google's server. No map.
- The map zoom was settable in the config file, but had no effect as the variable wasn't included in centerAndZoom function.
I added the missing entries to the config file, then updated the API V1 functions to their V2 counterparts (Google say V1 will be turned off in few weeks, so it has to be done). Last stop was a quick sweep through the php code of the included file to get the zoom variable installed and make sure the API key was being built into the final page.
Strangely, it all worked after I'd done this, even the preset zoom!
The downside is that the map is next to useless in my wiki pages. Firefox almost renders it, but panning it is a disaster. As for IE6! Not even worth looking… if it does render the page, panning it results in it falling apart, and bits of map just scatter themselves about the page. I suspect not the fault of the bolt on itself, but a combination of the skin (html + css) and wiki structure. We'll see what happens when the author sees my comments on his work (and my consultancy bill).