Dynamically Loading Google Maps api's

前端 未结 4 547
慢半拍i
慢半拍i 2021-01-05 04:00

Im trying to load the google maps api\'s dynamically. I\'m using the following code:

var head= document.getElementsByTagName(\'head\')[0];
var script= docume         


        
4条回答
  •  庸人自扰
    2021-01-05 04:30

    I've done it like so... this example uses jQuery and google map v3.x

    $.getScript("http://maps.google.com/maps/api/js?sensor=true®ion=nz&async=2&callback=MapApiLoaded", function () {});
    
    function MapApiLoaded() {
        //.... put your map setup code here: new google.maps.Map(...) etc
    }
    

提交回复
热议问题