-1

I want to use a view to render locations on a map, and dynamically update the map when a user filters the locations.

I have a view that displays a list of "Location" content types. That view exposes a "county" filter so that users can filter down to the Location's county. But this view is only able render the location text, and what I want is the locations rendered on a map.

How can I render a map that displays the locations, and updates when the user changes the county filter?

enter image description here

1

Check out the Geofield Maps module (https://www.drupal.org/project/geofield_map). You should then duplicate your Locations List View into a new view and change the display to be "Map". This will show markers for each of those locations. If desired you can then place that new Map View in the HEADER area of your above Locations List View (to get it placed where you mentioned in the picture).

In regards to the county filter, make sure the same filter exists in the new Map View also, then hide it with css. Now when you update the County filter, both the Map and List views will be filtered appropriately.

There's obviously a bit more nuance to setting up the Geofield Map view, but this should point you in the right direction.

3
  • Interesting, you're saying that by having the same filter on two views on the same page, one view will filter the other? – doub1ejack Feb 17 at 17:08
  • I've confirmed that I can filter the "List View" by using an exposed filter that specifies the address query param set by the "Map View". I used the "Geolocation field" module, but otherwise my solution mostly mirrors yours. Thanks! – doub1ejack Feb 17 at 17:11
  • Exactly, if you duplicate the filter it will update both views. Not sure if AJAX for that view needs to be disabled though. Worth checking. – Yuckle Feb 17 at 18:15

Not the answer you're looking for? Browse other questions tagged or ask your own question.