Skip Navigation

[Closed] WPViews view_addon_maps reload_map not working

This support ticket is created 4 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 3 replies, has 2 voices.

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

Assisted by: Christian Cox.

Author
Posts
#1860283

Tell us what you are trying to do?
We have a directory site with business listings, that we want to show on a map, above a grid of the listings. We can output the listings onto a map on page load, but after using the custom search filters with AJAX reload - the map is empty. I am calling the WPViews.view_addon_maps.reload_map method (code snippet below) on the js_event_wpv_parametric_search_results_updated event, but it does not reload the map. I know the search results updated event is firing - you can see the logs in the console.

I have found a number of support posts on your forums that reference WPViews.view_addon_maps.reload_map - but can't find any actual documentation of this method.

	jQuery(document).ready(function(){
		jQuery( document ).on( 'js_event_wpv_parametric_search_results_updated', function( event, data ) {
			console.log('js_event_wpv_parametric_search_results_updated called');
			var timeoutID = window.setTimeout( function(){
				WPViews.view_addon_maps.reload_map('directory-map'); 
				console.log('WPViews.view_addon_maps.reload_map called');
			}, 1000 );
		});
	});

Is there any documentation that you are following?
How to setup the view with map and posts:
https://toolset.com/lesson-placement/lesson-placements-1622939-1620853/

What is supposed to be the solution to my issue:
https://toolset.com/forums/topic/maps-in-tabs-ultimate-shortcode-2/

Is there a similar example that we can see?
I can't seem to find one.

What is the link to your site?
hidden link

You'll see the map corresponds to the listings when you load the page. But if you filter - for example, by town>Newport, there are listings in the grid below, but the map is empty, and it does not reload when I call the reload_map method.

You can look at the console to see when the output of the console.logs in the code snippet above.

I can provide an admin login to this staging site for you.

Also:
- The marker popup HTML does not work.

- Sometimes when I'm editing the map module in the content template, some of the settings are reverted to their defaults - such as the minimum number of markers in a cluster.

#1860745
Screen Shot 2020-11-29 at 2.44.14 PM.png

Hi, the reload_map JavaScript code usually shouldn't be necessary. The markers on the map should update automatically when the filtered results are loaded without the need to trigger the reload event manually. That's usually only necessary if a theme or plugin is controlling the block or blocks that contain the map block. Can you show me a screenshot of the map marker settings in the block configuration panel, as shown in the attachment?

Sometimes adding the current post's ID to the Marker ID using a shortcode will solve problems with the popup. Try adding the current post ID in the Marker ID field, like so:

marker-123-[wpv-post-id]
#1860869
Screen Shot 2020-11-29 at 4.22.33 PM.jpg
Screen Shot 2020-11-29 at 4.21.13 PM.jpg
Screen Shot 2020-11-29 at 4.18.25 PM.jpg

Hey Christian - thanks for getting back to me!

I'm still having trouble.

I want to confirm that I don't have to call the reload_map function in when I am filtering the view with "AJAX Refresh when changing any filter"?

The map is always empty whenever I filter, even when there are posts visible in the view. The map works properly when the page loads, which is why I believe there is something going on with the AJAX.

Did you look at the link I provided? hidden link

I'm attaching three screenshots to show you the admin interface with the custom search AJAX settings, and two of the map settings. These screenshots also shows that the popup works in the admin interface, but not on the front end.

Adding the [wpv-post-id] to the marker ID does not seem to have changed anything on the front end.

There is something not syncing up between the view loop and the map, I think, because the results aren't showing up when filtering, AND the markers are not showing up properly.

#1861597

Hi, yes I checked the link and I can confirm the problem you described. As you mentioned, if you reload the page, the markers appear on the map so something is going on with the AJAX process. However, as I said, it should not be necessary to call the reload event manually. I've set up a test to confirm this here: https://christiancox-22119-gyms-1.discover-wp.com/ajax-test-1/

If you have a free profile on our sandbox site https://discover-wp.com, I can give you an admin login so you can see how this is configured. I haven't added any extra JavaScript to reload the map, and you can see that filtering with AJAX triggers the map to update automatically. Popups work here too, so something else is going on, or there is a setup difference in our sites that is contributing to the issue.

May I log into your staging site admin area to see if there is anything obviously different in our setups? I can try to pin down the differences and see if there is a better way to set up your Views and templates, or if there is a 3rd-party plugin or theme contributing to some conflict. Private reply fields are available here.

The topic ‘[Closed] WPViews view_addon_maps reload_map not working’ is closed to new replies.