Here's my conundrum: I have a page that uses Google Maps V3 and jQuery. It all worked well locally in FF5, Chrome and Safari.
Once I uploaded to a web site, I get a "google is not defined" error on the first line that I try to use a google object
var defaultLocation = new google.maps.LatLng(lat, lng);
It only occurs in FF and only occurs remotely (i.e., if I load the file into FF locally, it works well). Chrome and Safari seem to be working great regardless, as is my Android and iPod browsers.
Here's what I tried so far:
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
to top of the <head>
section.$(function() {...});
to a function called initialize()
and added <body onload="initialize()">
But since this is only happening in FF on a remote machine and works well otherwise, I don't think it has anything to do with my code. Maybe the load order in FF5 is screwed. Maybe it prioritizes network resources differently than other browsers. I really do not know what to make of it at this point.
Any help is appreciated.
Guy
Update:
Just wanted to add the following fact: After trying the previous on a Mac, I tried FF5 in Windows, and have replicated the exact same behavior.
For good measure, I tried Pale Moon as well - same results. Chrome 14, Opera 11.50 and even frickin' IE9 (which wasn't included in the test plan) work. It just FF5, now on both Mac and Windows 7, that fails on that page.
In summary, it's always caused by trying to use the Google Maps API (or some other Google API) before it's loaded. This can be fixed by either changing up the import order, using something like jQuery to run your code after the whole page has loaded, or by making sure your browser isn't the problem.
You may need to update your Google Maps app, connect to a stronger Wi-Fi signal, recalibrate the app, or check your location services. You can also reinstall the Google Maps app if it isn't working, or simply restart your iPhone or Android phone.
You can do that by accessing Application restrictions, then navigate to “HTTP referrers” then type in your domain's name. After making the necessary changes, click Save. Copy the API key because you will need it to get the map back on your website.
I faced 'google is not defined' several time. Probably Google Script has some problem not to be loaded well with FF-addon BTW. FF has restart option ( like window reboot ) Help > restart with Add-ons Disabled
I had the same error "google is not defined" while using Gmap3. The problem was that I was including 'gmap3' before including 'google', so I reversed the order:
<script src="https://maps.googleapis.com/maps/api/js?sensor=false" type="text/javascript"></script> <script src="/assets/gmap3.js?body=1" type="text/javascript"></script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With