Google Maps API JavaScript error when GBrowserIsCompatible() is called

前端 未结 4 829
名媛妹妹
名媛妹妹 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:45

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

    
    

    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.

提交回复
热议问题