How to make a callback to Google Maps init in separate files of a web app

后端 未结 2 1015
刺人心
刺人心 2020-12-10 06:20

When I had my Google Maps API snippet:



        
2条回答
  •  情歌与酒
    2020-12-10 06:58

    I could fix it in my code by using the callback and declaring the initMaps function on window as you did:

    window.initMap = function(){
      //...
    }
    

    However, the trick was to load my custom JS (which also includes the above declaration of initMaps) before loading Google Maps:

    
    
    

    Hope this helps.

提交回复
热议问题