Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Forget about closures for a moment. You can dive into those once you get a working app. I think you're goal at this point to should be to just get something that accomplishes what you want. </p> <p>To me, it seems like the only piece you're missing is the idea of a <a href="http://en.wikipedia.org/wiki/Callback_function" rel="nofollow noreferrer">callback function</a>. For instance, addElementToList would be passed as the callback argument to <a href="http://code.google.com/apis/maps/documentation/reference.html#GClientGeocoder" rel="nofollow noreferrer">geocoder.getLocaitons</a>. The way it works is that when getLocations() finishes, it calls addElementToList and supplies the result from getLocations() as an argument to addElementToList. The code for addElementToList will then add your store location to the map as a marker and add a new element to your html list with the store's name or address or whatever. </p> <p>Take a look at this blog post for a simple example using a callback: <a href="http://www.developer.com/lang/jscript/article.php/3615681" rel="nofollow noreferrer">Introducing Google's Geocoding Service</a>. </p> <p>The last part, centering on a specific store, can be done (as you suggested) with event listeners. You can set up a listener for clicks on the markers and also for clicks on your list. When you add a marker, <a href="http://code.google.com/apis/maps/documentation/events.html#Event_Listeners" rel="nofollow noreferrer">you can also add an event listener on it</a>. It'd be nice if you could set one listener for all markers on the map but I'm not familiar enough with google's API to know if this is possible.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload