Skip Navigation

[Resolved] Display a list of items visible on a map

This support ticket is created 5 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 1 reply, has 2 voices.

Last updated by Christian Cox 5 years, 6 months ago.

Assisted by: Christian Cox.

Author
Posts
#1359125

Tell us what you are trying to do?
Display a list of items visible on a map. Because of the amount of items on the map i would only like to display the items visible in a specific zoom level of the map. Is it possible to filter the list below the map to only show items that have markers on the current zoom level.

Is there any documentation that you are following?
https://toolset.com/documentation/user-guides/maps-shortcodes/

Is there a similar example that we can see?
Not exactly what i mean but this might give you an idea:
hidden link

On this site it works the other way around, if i select a category only those items belonging to the category will show in the list an d on the map.

What is the link to your site?
hidden link

#1359247
Screen Shot 2019-10-09 at 4.23.33 PM.png

Hi, I think I understand. Like when I search for a restaurant on Google Maps, then move the map. I can see a message "Search within this area", and if I click that only the visible markers would appear in the list of results. Unfortunately this type of search does not exist in Toolset Maps. You could probably accomplish something similar with custom JavaScript code. You would create a View that includes all the results, and place all the markers on the map. Then use map.getBounds() to determine the boundaries of the map, and inspect each marker to see if it's within the bounds. Here's an example:
https://jsfiddle.net/glafarge/mbuLw/

Then you can turn on or turn off the corresponding results with CSS.

You can find the map objects here:

WPViews.view_addon_maps.maps

You can find the marker objects here:

WPViews.view_addon_maps.markers

Info about changing map settings programmatically:
https://toolset.com/documentation/user-guides/programmatically-change-map-settings/

A screenshot here shows the map event hooks available for attaching your own custom code. If you'd like to see this type of search filter added to maps, feel free to submit a feature request here:
https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/