Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
151
rated 0 times [  153] [ 2]  / answers: 1 / hits: 26515  / 13 Years ago, fri, september 2, 2011, 12:00:00

i have a problem with displaying GoogleMap.



Here is the website source code: http://pastebin.com/LjhVbEF7



When i'm trying to run this website, map is not displayed.
Firebug console says Uncaught TypeError: Cannot read property 'offsetWidth' of null



Have you any idea what am i doing wrong? I know that there are many working examples on the net but this code is generated by a special script and i'm not able to interfere it to much. Maybe i forgot to set some variables?



thanks,
Mike



=================



EDIT:
This code is working only when i'll put JS in function definition and call it in body onload param. Do you have any idea how can i make it working without using such function and onload param ?


More From » google-maps

 Answers
55

I realise that this is probably a bit late - but hopefully it will be able to help someone else out:



In your case the initialise function is not firing, although it can also be caused by the width and height attributes not being set on the container div. If you don't want to simply add the load event to the body tag you can use the following jQuery:



//Add onload to body
$(window).load(function(){
initialize()
});

[#90298] Wednesday, August 31, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
alfonsok

Total Points: 386
Total Questions: 101
Total Answers: 90

Location: Puerto Rico
Member since Sun, Jun 27, 2021
3 Years ago
;