Skip Navigation

[Resolved] Center map when no search results are found

This thread is resolved. Here is a description of the problem and solution.

Problem: When no results are found, the map displays somewhere off the coast of Africa. How can we manipulate that center point?

Solution: One solution is to move the map shortcode inside the wpv-items-found shortcode of the View's loop editor. That will hide the map completely when no results are found. Another solution is to use custom JavaScript with the Maps API.

This support ticket is created 5 years, 1 month 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 2 replies, has 2 voices.

Last updated by maxfieldB 5 years, 1 month ago.

Assisted by: Christian Cox.

Author
Posts
#1371093

Tell us what you are trying to do?
When no search results are found, my map centers off the coast of Africa. How can I control where the default view of my map is centered?

Is there any documentation that you are following?
No

Is there a similar example that we can see?
No

What is the link to your site?
hidden link

#1371125

Hi, one way to control this is to move the wpv-map shortcode inside the View's wpv-items-found section. When you have no results, the map will not be displayed at all. The other option is custom code, using Google Maps JavaScript API. If you have knowledge of JavaScript I can show you a few event hooks you might find useful, as well as the location of the Google Maps objects used by Views.

#1372675

Thank you - we will move the map inside the view so that the map hides itself when there are no results - thanks!