Uncaught ReferenceError: google is not defined

前端 未结 3 2043
再見小時候
再見小時候 2020-12-08 22:03

I want to use geolocation and direction function, but there is google is not defined error. the code is as below:

function loadScript() {
               


        
3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-08 22:40

    I tried it on my own with this code - it worked fine for me

    Dynamic with key

    
    
    
        
        
        
    
    
        

    Static without key

      ...
    
    
    
       ...
    

    When surfing through the net I tumbled over an important note!

    Google Maps JavaScript API v3

    The Google Maps JavaScript API v3 does not require an API key to function correctly. However, we strongly encourage you to load the Maps API using an APIs Console key which allows you to monitor your application's Maps API usage. Learn how to use an APIs Console key.

    See Google Maps API

    So, apparently you no longer need a developer key! I tried it with both - static no key and dynamnic with key - both worked.

提交回复
热议问题