maletor maletor - 6 months ago 9
Javascript Question

Dragging map changes search results

How would you implement draggable search results with Google maps API v3 akin to the way Yelp does.

My guess is that you would bind to a map move event and link to an anchor like

#l=g:-122.47764587402344,37.75225820732335,-122.37464904785155,37.83419172060041
and pass those bounds through to the search.

Btw, this is for a Rails project.

Answer

Here's the Map reference: http://code.google.com/apis/maps/documentation/javascript/reference.html#Map

The event "bounds_changed" seems to be what you want. When it fires you should get the map boundaries using map.getBounds() and pass that along to your search.

Comments