Google Maps API – setCenter is crucial

I have just learned two things about Google Maps API.

First, that setCenter method MUST be called just after map creation.

Second one, that map has to be contained in div HTML tag.

Without that (second thing), in IE You got strange erorr during using such a map (well it is just not usable). It is run-time error, and when followed with Microsoft Script Debugger it halts on line 31 in function Hb from http://maps.google.com/mapfiles/maps2.65.api.js on following code a.innerHTML=b

Well… I hate IE :-)) I was hunting for this bug for some time. Of course I made a mistake, I don’t blame IE for behavior in line with Google Maps documentation. Shame for not having such good tools like Venkman and WebDeveloper Toolbar for Firefox/Flock.

In despair I have copied HTML/JS code generated from RubyOnRails application to plain HTML files and stated cutting off content from it, until it was almost so simple as Simple example from Google Maps documentation. Since cutting off more advanced features and code didn’t helped with my application, I was able to spot difference comparing Simple code…

I’m quite new to JS and I had a lot such issues when I was testing it with FF or Flock. But with Venkamn and WebDeveloper I was able to squeeze my bugs in matter of minutes. When bug was IE only related… Well I was flaming a lot!

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.