How do I load google maps external javascript after page loads?

前端 未结 4 625
感动是毒
感动是毒 2020-12-14 15:34

I will provide more information to explain my situation. I am building an application with PhoneGap for deployment on iOS. I have a a view/page that user will navigate to (n

4条回答
  •  无人及你
    2020-12-14 16:28

    //Using jQuery's getScript function

    $.getScript('[js containing the initialize function]',function(){
        $.getScript('https://maps.googleapis.com/maps/api/js?v=3.exp&callback=initialize');
    }); 
    

    Explanation:

    First load your external script containing the initialize function and upon callback, load the google map API with callback equals to initialize.

提交回复
热议问题