Skip Navigation

[Resolved] Hide map if no results in search

This support ticket is created 3 years 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.

Our next available supporter will start replying to tickets in about 0.99 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 6 replies, has 3 voices.

Last updated by bxbM 2 years, 12 months ago.

Assisted by: Waqar.

Author
Posts
#2015281
Screenshot_2021-04-08 Search HVAC Pros - Midwest Air Pros.png

Tell us what you are trying to do?
Hide map if no results in search. I would like the search results to just say "No companies found" or at least hide the map so it doesn't show Lat0 and Long0 when the search results are empty

Is there any documentation that you are following?

Is there a similar example that we can see?

What is the link to your site?

#2015631

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi there

Are you using the blocks interface and View and Map blocks to create this custom search, or the legacy interface?

It is possible to set a default centre for the map when there are no markers to display (because there are no search results), but it is not obvious how you can do that (we have an internal ticket to improve that UI).

Assuming you are using Blocks, in the settings for the Map block

- turn off the setting Adjust zoom and center to show all markers at once
- that will expose settings to manually set the latitude and longitude (plus zoom level) of the map. These will be used when there are no markers, so set them to sensible values
- turn the setting Adjust zoom and center to show all markers at once back on

#2015635

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

{ticket status updated}

#2016025
Screenshot_2021-04-09 Edit Page ‹ Midwest Air Pros — WordPress.png

When attempting to change settings on map block I get this error message, but the map block is not inside the view block. No settings appear in the sidebar.

#2017987

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thanks for sharing the screenshot and it is strange that you're seeing that message.

Can you please share temporary admin login details so that I can see how this view is set up?

Note: Your next reply will be private and please make a complete backup copy, before sharing the access details.

#2027109

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for sharing these details.

If you'll check the block structure of your "Search HVAC Pros" page, you'll see that the "Maps" block is indeed placed within the "Views" block, which is why you're seeing the error message.
( screenshot: hidden link )

To change the Map block's settings, you'll need to temporarily drag it out of the "Views" block and adjust the settings as needed. After that, you can move it back to the position you'd like it to appear.

For hiding the map, when no results are returned by the view, you can place the following CSS code, below the view's "No Items Found Text".
( screenshot: hidden link )


<style>.wpv-view-output .wpv-addon-maps-render {display: none;}</style>

#2029057

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.