Google Maps API: TypeError: a is undefined

前端 未结 3 1779
忘了有多久
忘了有多久 2020-12-06 09:31

I have searched this problem all over the web and none of them seem to give me any resolution. I have a simple script to just display the map of South Africa.



        
相关标签:
3条回答
  • 2020-12-06 10:01

    Version 3.30+ is affected of this problem if there is a global var called Map.

    ex:

    <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=YOURKEYHERE&v=3&callback=init" async defer></script>
    <script type="text/javascript">
        function init() {
            Map.go();
        }
        var Map = {
            go: function() {
                console.log("start engine");
            }
        };
    </script>
    

    We got this error:

    TypeError: a.prototype is undefined

    Renaming window.Map then everything goes fine.

    0 讨论(0)
  • 2020-12-06 10:12

    I've also seen this error often in the last days, there seems to be an issue with the experimental API-version.

    Load the release-version instead(basically you should always load the release-version in production)

    <script language="javascript" src="https://maps.googleapis.com/maps/api/js?sensor=true&v=3"></script>
    
    0 讨论(0)
  • 2020-12-06 10:13

    Google Maps started to through errors when loading the script and on touch events. I'm using it for a cordova application on Android and iOS.

    These are the errors I get but changing the load version didn't solve it.

    <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=MYKEY&v=3.21&libraries=geometry,places"></script>
    
    0 讨论(0)
提交回复
热议问题