How do I use the automatic loading features of Google Maps?

I started reading about auto-loading google map at:

http://code.google.com/apis/ajax/documentation/#AutoLoading

It is not clear to me how to actually load the google map.

I tried:

<script src="http://www.google.com/jsapi?autoload=%7B%22modules%22%3A
%5B%7B%22name%22%3A%22search%22%2C%22version%22%3A%221.0%22%2C
%22language%22%3A%22en%22%7D%2C%7B%22name%22%3A%22maps%22%2C%22version
%22%3A%222.X%22%7D%2C%7B%22name%22%3A%22elements%22%2C%22version%22%3A
%221.0%22%2C%22packages%22%3A%5B%22localsearch%22%5D%7D%5D
%7D&key=MY_KEY"></script>
<script type="text/javascript">
//<![CDATA[
        google.load("maps", "2.x");
        google.setOnLoadCallback(function() {
                map = new google.maps.Map2(document.getElementById("map"));
                map.setCenter(new GLatLng(37.4419, -122.1419), 6);
                map.addControl(new GSmallMapControl());
                }
        );
//]]>
</script>

      

But the map won't load.

The weird thing is that if I just remove the " autoload=

..." from the url the map loads and works fine.

If I save autoload=

... in the url and comment out the manual load " google.load("maps", "2.x");

", it still doesn't work.

Any ideas on how to properly use the auto-download features to get the highest performance (lowest latency)?

+1


a source to share


1 answer


You must use:

<script src="http://www.google.com/jsapi?autoload=%7B%22modules%22%3A
%5B%7B%22name%22%3A%22search%22%2C%22version%22%3A%221.0%22%2C
%22language%22%3A%22en%22%7D%2C%7B%22name%22%3A%22maps%22%2C%22version
%22%3A%222.X%22%7D%2C%7B%22name%22%3A%22elements%22%2C%22version%22%3A
%221.0%22%2C%22packages%22%3A%5B%22localsearch%22%5D%7D%5D
%7D&key=MY_KEY"></script>

      



Nothing else. Remove the code after this in your example

0


a source







All Articles