You're loading the Javascript API on the home page of your web site
(http://svn.rectmedia.com/webrepo/p25cruffs/website/), and initializing a
map object with a DOM Node ("map_canvas") that isn't present or available on
your home page:
var map = new google.maps.Map(document.getElementById('*map_canvas*'), {
'zoom': 18,
'center': mapCenter,
'mapTypeId': google.maps.MapTypeId.ROADMAP
});
Using Chrome on the home page I see the "null" error in the Javascript
console:
1. Uncaught TypeError: Cannot read property 'offsetWidth' of null
1.
The div element named "map_canvas" is only present when you go to your
"Contact Us" page
(http://svn.rectmedia.com/webrepo/p25cruffs/website/contact-us), which is
why there's no error thrown on that page.
I would not recommend loading the API on the home page, since you're not
showing a map there anyway. It would count as a page view unnecessarily.
If your home page and contact page are sharing code, you could load the
API dynamically (rather than statically) in an event handler that's
initiated when the user views the contact page.
See
http://code.google.com/apis/maps/documentation/premier/guide.html#CommonLoader
(which also points you to
http://code.google.com/apis/maps/documentation/javascript/v2/basics.html#AJAX_Loader)
for an example of dynamic, on-demand loading of the API. Your event handler
that would be triggered by viewing the contact page would call
"google.load('maps', '3.5', ...)", and set a callback function for when it's
loaded using "google.setOnLoadCallBack(fn)" where the callback function is
basically what you have as your initialize function.
Or a more simple approach at
http://code.google.com/apis/maps/documentation/javascript/basics.html#Async,
where you would call "loadScript()" when you're ready to show a map (again
with a callback for when it's loaded).
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-maps-js-api-v3/-/r_OfKU424ywJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-js-api-v3?hl=en.