initMap is not a function

前端 未结 4 411
南旧
南旧 2021-01-23 01:35

I can\'t understand what is the problem? I used this example from Google Map APIs: Simple Map


   
   
4条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-23 02:36

    I had the same issue working on a wordpress template with Sage (a WordPress starter theme).

    My js was wrapped with

    (function($) {
    
    // all the functions to create map, center markers, etc.
    
    }
    

    Then, the map was initialize in $(document).ready

    I removed (function($) { } and just add the functions without $(document).ready then it was ok.

    Also, be sure to load the custom js file before the api google map :

    
    
    
    

提交回复
热议问题