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 lien caché
initMapOrWaitIfInsideHiddenBootstrapAccordionOrTab lien caché
init_map_after_loading_styles lien caché
jQuery 9
init_map_after_loading_styles lien caché
ViewAddonMaps lien caché
jQuery 7
reload_map lien caché
N Underscore
ViewAddonMaps lien caché
jQuery 7
manage_update_results lien caché
jQuery 41
manage_update_results lien caché
manage_changed_form lien caché
jQuery 7
get_updated_query_results lien caché
manage_changed_form lien caché
ViewParametricSearch lien caché
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();
});
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
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: lien caché
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.
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
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.
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