Can you load Google Maps API v3 via Google AJAX API loader

后端 未结 2 1201
栀梦
栀梦 2021-02-03 13:37

Some time ago I used the regular method of loading Google Maps API like this:



        
相关标签:
2条回答
  • 2021-02-03 14:24

    It's undocumented, but it works.

    google.load("maps", "3", {other_params:'key=YOUR_API_KEY', callback: function(){
      var map; // initialize your map in here
    }});
    

    [EDIT] The documentation now requires the use of an API key that is passed to the loader as a "key" parameter. I've removed 'sensor=false' as a parameter because it is now explicitly not required and throws a warning when provided.

    0 讨论(0)
  • 2021-02-03 14:40

    this example work perfectly.

    //Set google Api
    <script type="text/javascript" src="http://www.google.com/jsapi"></script>
    //Initialize General
    <script type="text/javascript">
        //Add Jquery, if you need
        google.load("jquery", "1.7.1");
        //Initialize Map, with option sensor=false
        google.load("maps", 3, {other_params:"key=YOUR_API_KEY"});
        //Initialize Map's
        google.setOnLoadCallback(function() {
                var options = {
                      zoom: 10,
                      center: new google.maps.LatLng(-34.616507,-58.409463),
                      mapTypeId: google.maps.MapTypeId.ROADMAP
                }
                map = new google.maps.Map(document.getElementById('map_canvas'), options);
        });
    
    
    </script>
    
    0 讨论(0)
提交回复
热议问题