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…

  1.  Used GMap instead of GMap2
  2. Used Gpoint instead of GLatLng
  3. Used centerAndZoom instead of setCenter

Stable? Weeeellllllllllll…

  1. 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.
  2. The value was just left blank, instead of being set to " ".
  3. 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.
  4. 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.
  5. 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!

I couldn't currently have created the code, my php isn't up to it, and the JavaScript of the API is a nightmare to me (especially one the DOM get mixed in, and a bit of XML), but something must be sticking since I was able to spot the problems and get this working better than it had been before.

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).


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: