Google Map fails to start in Chrome but works on FF and IE

76 views
Skip to first unread message

Eric!!

unread,
Nov 5, 2010, 12:40:19 PM11/5/10
to Google Maps JavaScript API v3
I wrote a javascript tool that works with blogger.com and allows
people to put geo-location information into each post and then it
plots them on the googlemap on the page.

This script has always worked fine with Firefox and IE7/8, however
Chrome fails to start the googlemap. I've tried using version 2 and 3
of the API. I've tried manipulating some of the on_load functions but
nothing seems to work for Chrome. It appears that it is immediately
trying to access the API before it has loaded the DOM fully and it
fails immediately. This is just a guess, but I'm really stuck....

I'm using a <body onload="start_map()"> tag to allow the DOM to load
before running the API, however Chrome seems to abort trying to load
the map immediately from google.

Here's a link to the page (currently using v2 of the API...I know
don't shoot me):
http://svnakia.blogspot.com

Any ideas or help would be appreciated!

Eric

Rossko

unread,
Nov 5, 2010, 4:00:35 PM11/5/10
to Google Maps JavaScript API v3
> I'm using a <body onload="start_map()"> tag to allow the DOM to load
> before running the API, however Chrome seems to abort trying to load
> the map immediately from google.
> ... http://svnakia.blogspot.com

I don't have Chrome to try, but
<body onload="start_map()" ...
window.attachEvent('onload', function(){ ...
look to be mutually incompatible to me. It'll depend on the browser
exactly which onload events get destroyed by the other method, but you
need to avoid using the <body> method if you are are trying to attach
more than one function to onload.

Chad Killingsworth

unread,
Nov 5, 2010, 4:34:56 PM11/5/10
to Google Maps JavaScript API v3
You are using a v2 map. Try asking your questions here:
http://groups.google.com/group/google-maps-api

Chad Killingsworth

Eric!!

unread,
Nov 6, 2010, 11:34:48 AM11/6/10
to Google Maps JavaScript API v3
As I mentioned I've tried both API v2 and v3 with no difference.

On Nov 5, 1:34 pm, Chad Killingsworth

Eric!!

unread,
Nov 6, 2010, 11:37:33 AM11/6/10
to Google Maps JavaScript API v3
Initially I thought that too. So I removed the window.attachEvent
section of the code inserted by blogger.com while playing with it on
my own server so that the body on_load call is all that should be set
as a trigger and Chrome still fails to start the googlemap.

Eric!!

unread,
Nov 6, 2010, 12:04:21 PM11/6/10
to Google Maps JavaScript API v3
In fact, here it is without the blogger.com javascripts, just my stuff
(and a different API key for the different domain of course)

http://www.sailsarana.com/maps/test.html

Same problem only with Google Chrome.

Eric!!

unread,
Nov 6, 2010, 12:17:02 PM11/6/10
to Google Maps JavaScript API v3
Ok, and I made one more subset of this, stripping out all of the
parsing and putting points on the google map. This script is pretty
basic and it just tries to start a google map, which only fails in the
Google Chrome browser.

http://www.sailsarana.com/maps/test2.html

any ideas? (again I've also tried API v3 on this too, same results)

Eric!!

unread,
Nov 6, 2010, 1:16:55 PM11/6/10
to Google Maps JavaScript API v3
I've been able to isolate to a Javascript problem with reading the
DOM. In particular

var d=window.content.document.body.innerHTML;

Causes Google Chrome to abort the routine. I still don't have a work
around, but it is progress.

Esa

unread,
Nov 7, 2010, 4:48:06 AM11/7/10
to Google Maps JavaScript API v3


On Nov 6, 7:16 pm, "Eric!!" <t...@sailsarana.com> wrote:

> var d=window.content.document.body.innerHTML;
>
> Causes Google Chrome to abort the routine.  I still don't have a work
> around, but it is progress.

Chrome reports:

"Cannot read property 'body' of undefined"

meaning that window.content.document is undefined. No wonder to me
because I never seen such an object before.

Why not try addDomListener() that is a cross browser method.

google.maps.event.addDomListener(window, 'load', start_map);

Arlo

unread,
Nov 7, 2010, 11:11:46 AM11/7/10
to Google Maps JavaScript API v3
LIke you said: var d=window.content.document.body.innerHTML;

Is the culprit. Use "document.body".
Reply all
Reply to author
Forward
0 new messages