I have tried to search for instructions for, or any slightest hint of the possibility of, filtering a given list of addresses by the map area that WebUI user has currently zoomed into in a Google Map, which is installed into a Drupal 7 website with GMap.

All documentation and instructions that I find on the topic discuss information exchange in the opposite direction: you give an address (or a set of addresses), and the Google map gets zoomed comfortably around the given address(es).

But I need the opposite of this: The map area chosen by user should filter out any addresses (manually configured hand-picked locations, stored in an array in Drupal) which are not within the map area currently visible to the user, as the user freely zooms and drags the map. The map area should affect the address list, not vice versa.

An example: Assume that the website of a store chain shows a list of shops in left column, and a country map in right column. Every shop is marked with a dot on the map. (We can arrive here with the traditional direction of information exchange: Drupal gives a list of shop addresses to GMap, and GMap returns a map which is zoomed around these addresses, and shows each of these addresses.) Then the user zooms the map into his own city, and his own street. As this happens, we want to hide from the list of shops any shop which is not within the visible map area. Drupal should somehow receive from GMap a hint, which of the listed addresses are within the visible map area, and which are not.

Any instructions available?

Comments

jomitt’s picture

A possibility comes in mind: Can GMap tell Drupal the geographical coordinates within which the currently visible map area is cropped? If yes, and if we have in advance stored into Drupal variables the coordinates of the listed addresses, it would be simple math to filter out any listed address whose vertical coordinate is outside of the vertical coordinate limits of the visible map area, or whose horizontal coordinate is outside of the horizontal coordinate limits of the visible map area.

Jaypan’s picture

This can be done, but you'll need to create your own custom JS script and tie in with the Google Maps API. You can get the current boundaries of the map at any given time, the use ajax calls to adjust the items displayed.

jomitt’s picture

Sounds doable.

By what means do I "get the current boundaries of the map at any given time"? Does the API return this information?