views:

157

answers:

1

I am using Google Maps v3.

I'm currently using the autoload functionality and it's working great:

<script type="text/javascript" src='http://www.google.com/jsapi?autoload={modules:[{name:"maps",version:3,other_params:"sensor=false"}]}'&gt;&lt;/script&gt;

Now I want to use the autoload to also include the callback option to callback my function named myCallbackFunction().

How do I modify my working code above to include the callback option?

I've tried a few different ways and none work. I receive an "Invalid Autoload" error.

The API is linked

UPDATE:

I've tried the below, as well as a ton of other variations and none work. I still cannot figure out the appropriate syntax to use the callback method.

<script type="text/javascript" src='http://www.google.com/jsapi?autoload={modules:[{name:"maps",version:3,other_params:{"sensor=false","callback=myCallbackFunction"}]}'&gt;&lt;/script&gt;
A: 

Do you have to use the Google AJAX loader and autoload? They even mention in the documentation it should be used as a last resort: "This advanced feature can be difficult to implement, depending on the exact situation. Therefore, we recommend that auto-loading only be considered in specific cases when a reduction in latency is crucial."

You could just directly load the maps API asynchronously and specify a callback, a la the answer to this FAQ and example.

Andrew