Skip Navigation

[Resolved] re-initialize map after search button clicked

This support ticket is created 2 years, 4 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 5 replies, has 2 voices.

Last updated by Shane 2 years, 4 months ago.

Assisted by: Shane.

Author
Posts
#2412413

I'm not showing the map with results until after a user has set search filters and clicked search button with a php filter on "wpv_filter_query_post_process"

But in this case, the map never appears and I get some jQuery errors shown in console:

Uncaught TypeError: self.api is null
init_map hidden link
initMapOrWaitIfInsideHiddenBootstrapAccordionOrTab hidden link
init_map_after_loading_styles hidden link
jQuery 9
init_map_after_loading_styles hidden link
ViewAddonMaps hidden link
jQuery 7
reload_map hidden link
N Underscore
ViewAddonMaps hidden link
jQuery 7
manage_update_results hidden link
jQuery 41
manage_update_results hidden link
manage_changed_form hidden link
jQuery 7
get_updated_query_results hidden link
manage_changed_form hidden link
ViewParametricSearch hidden link

Do I need to initialise the map after a the search button is clicked?

I'm trying te following, but it's not working.

jQuery( document ).on( 'js_event_wpv_parametric_search_results_updated', function( event, data ) {
WPViews.view_addon_maps.init_maps();
});

#2412613

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi David,

Thank you for getting in touch.

Not sure what you mean by here I'm not showing the map with results until after a user has set search filters and clicked search button with a php filter on "wpv_filter_query_post_process"

Secondly does the map load normally on a fresh view and a search is performed?

Please let me know.

Thanks,
Shane

#2413157

Hi Shane,
Sorry for not being clear.
When a user views the page for the first time, they see only the search filters but no results. This is set with a filter in functions.php according to: https://toolset.com/forums/topic/views-search-show-no-results-until-search-option-entered-and-add-pagination/

But without that filter, then the map does load normally.

Take a look here: hidden link

You will see that when you set a search filter that results are generated and even a space is created where the map should display, but the map is not visible.

It's another issue, but this map is very slow. There are over 4,000 posts and it is creaking. That's one of the reasons that I'm looking at this approach, because showing the map on page load with all results is very slow. If you have any suggestions about that, then I'd also like to hear them.

Thanks.

#2413265

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi David,

Where on the view the map was added? I suspect that this was added in the [wpv-items-found] shortcode ?

There is a different way to perform this exact same query of starting without any results that makes use of our conditionals and this should get your view's map to work regardless.

Please let me know if you want to go ahead and try this.

Thanks,
Shane

#2413271

Yes, the map is in [wpv-items-found].

I would like to try the method you suggest.
How does that work? How would I do that?

Thanks.

#2413281

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi David,

All you need to do is to wrap all your content that is within the [wpv-items-found] into the following conditional.


[wpv-conditional if="('[wpv-search-term param='wpv_view_count']' ne '')"]

Content goes here
[/wpv-conditional]


What the above shortcode will do is to check for a specific parameter that is only there on the view when a search is being performed.

Please let me know if this helps.
Thanks,
Shane