Google Maps API JavaScript error when GBrowserIsCompatible() is called

前端 未结 4 816
名媛妹妹
名媛妹妹 2021-01-24 22:02

I get an error on the following line:

 if (GBrowserIsCompatible()) {

this is my code still not working



        
相关标签:
4条回答
  • 2021-01-24 22:37

    I've had the same problem with internet explorer if the page was viewed with https protocol (instead of http). Are you using it via https or http? Anyway with https there will be warnings unless you pay something like 10 000$ to google.

    0 讨论(0)
  • 2021-01-24 22:45

    Did you load the Google Maps API with your own API key?

    <script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ENTER_API_KEY_HERE'></script>
    

    Source: http://code.google.com/p/jmaps/issues/detail?id=12


    Update

    Check out the troubleshooting page for IE.

    Maybe you're checking for it too early. Try something like this:

    var iterations = 0;
    function check_compat() {
        if (iterations === 75) {
            alert('Failed to load Google Maps API. Clear your browser cache, open Google Maps then try again.');
            return;
        }
        if (typeof GBrowserIsCompatible === 'undefined') {
            // It isn't loaded, schedule the next check.
            setTimeout(check_compat, 200);
            iterations++;
        } else {
            if (GBrowserIsCompatible()) {
                mapReadyFn();
            } else {
                alert('Sorry, your browser is not supported.');
            }
        }
    }
    

    After that, just replace this line:

    if (GBrowserIsCompatible()) {
    

    with this:

    function mapReadyFn() {
    

    If it fails for 15 seconds, it stops trying and you get an error.

    0 讨论(0)
  • 2021-01-24 22:49

    I too had the Same Issue. When i checked with the Example program at http://universimmedia.pagesperso-orange.fr/geo/loc.htm it was Working fine; but When i Changed the API Key Value to that of mine, I got the Error at Gbrowser Line., After checking with my Google Account API., I realized that there are two Google Map API Versions 2 & 3 AND I have enabled only 3 and was referring the Map in the java Script., When i Enabled the API Version 2., The error is Fixed. Try it out and give your feedback.

    0 讨论(0)
  • 2021-01-24 22:56

    The answer from @Andrew S now seems to be the best, since v3 is now the only available version of the API. There is no GBrowserIsCompatible method, nor is there any replacement. I'd guess it would be best to check some web APIs (e.g., geolocation) you intend to use before invoking maps APIs.

    Google Maps v2 to v3: Removing Obsolete Code

    0 讨论(0)
提交回复
热议问题