You can download the Google Maps API v3 through the Google AJAX API Loader

Some time ago, I used the usual way to load the Google Maps API as follows:

<script type="text/javascript" src="http://maps.google.com/maps?file=api&v=2&key=abcdefg&sensor=true"> 

Later I switched to the Google AJAX API to download the Google Maps API. This is because several “widgets” on my website need the Google Ajax API, so I decided to be consistent and used the AJAX API to load Google Maps:

 <script type="text/javascript" src="http://www.google.com/jsapi?key=abcdef"></script> <script type="text/javascript"> google.load("maps", "2", {"other_params": "sensor=true"}); </script> 

Now that I finally decided to use the Google Maps API v3, this page does not list the API v3 in the list of available versions. None of the API v3 documentation examples show the use of the AJAX API. Is it possible (and supported) to download the Google Maps API v3 through the AJAX API loader?

+7
source share
2 answers

This is 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, which is passed to the loader as a key parameter. I removed the parameter "sensor = false" as a parameter, because now it is clearly not required and it displays a warning when provided.

+23
source

this example works great.

 //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> 
-one
source

All Articles