Skip Navigation

[Resolved] Google Maps [wpv-map-render] Argument “single_zoom” not working

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

Problem: The single_zoom parameter on my map View does not seem to be working.

Solution: In this case, the problem is that more than one result appears at the same exact location on this map, so the "single_zoom" setting never applies. It only applies when just one result is found, and it does not account for identical locations. So the other option here is to set a global maximum zoom level for this map.

jQuery(document).on('js_event_wpv_addon_maps_init_map_completed', function() {
  var options = {'maxZoom': 13};
  WPViews.view_addon_maps.get_map('map-1').setOptions( options );
});

Relevant Documentation: https://toolset.com/documentation/user-guides/display-on-google-maps/

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

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

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 11 replies, has 2 voices.

Last updated by Marco Bolleter 7 years, 2 months ago.

Assisted by: Christian Cox.

Author
Posts
#559511

I created a view (CustomerSearchMarkte) for CPT post type "Markt" which shows multiple locations of the markets on Google-Map. When the filtered result in the view is only ONE, the zoom-level goes the the lowest possible, instead of the defined 5 [wpv-map-render map_id="map-1" single_zoom="5"].

Link to a page where the issue can be seen: hidden link and select in "nach Region" the value "Zürich"

#559700

This is tricky! It took me a while to understand what is happening here. The single_zoom setting only applies when the View includes a single result. This map shows 2 results at the same address:
hidden link
hidden link

Select "Erlebnis mit Tieren" and "St. Gallen" and you will see the single zoom setting applied as expected for 1 result.

#559707

Hi, thank for the analysis, I was not aware of this.
So what can I do to get to an appropriate zoom level on the map? I will quite often have the situation, that few offers refere to the same market. I understand that technically we have two or several CPSs refereing to only ONE location on Goolge-Map.

Thanks for your help.

#559756

The only maximum zoom setting we provide is based on displaying a single result, and doesn't take into account multiple results at the same location. I think the best solution would require some custom JavaScript. Or, I could help you set a maximum zoom level for the map that would apply no matter how many results are found. Unfortunately if your users want to zoom past that level they will not be able to do so. Let me know how you would like to proceed.

#559804

For the time beeing the MAX-zoom level would be fine (if this is the easyer solution). This would only apply for this specific view I guess.
So, on another view, which shows the details of ONE market only (e.g. hidden link) the user would still be able to zoom to all levels?

#559991

No, the max zoom level will still apply no matter how many results are included or how many different locations are shown on the map. Your users will not ever be able to zoom past the max zoom level on this map, and if you set a higher number for the single_zoom value, the max zoom level will override it. Let me know how you would like to proceed.

#559993

Oh actually I just reread your comment and I may have misunderstood. You're asking about a different map, in a different View, correct? If so, then the maximum zoom level assigned to the homepage map will not apply here. It will only apply to maps that have the same ID as the map on the home page. As long as you use a different map-ID value for other maps, they will not have the max zoom level. Sorry for the confusion there.

#560015

Your last comment, understanding is fully correct. That would work fine for me.

#560086

Okay great. In your View editor, open up the JS panel underneath the Loop Output editor. Add the following code:

jQuery( document ).ready( function() {
  var options = {'maxZoom': 15};
  WPViews.view_addon_maps.get_map('map-1').setOptions( options );
});

Then test the map again. You can increase or decrease the number 15 however you would like to modify the maximum possible zoom (a lower number means map is zoomed out more)

#560241
WPView error IsNotAFunction.jpg

I get the following error - check attached image.
Uncaught TypeError: WPViews.view_addon_maps.get_map(...).setOptions is not a function
at HTMLDocument.<anonymous> ((index):613)
at i (jquery.js?ver=1.12.4:formatted:1337)
at Object.fireWith [as resolveWith] (jquery.js?ver=1.12.4:formatted:1391)
at Function.ready (jquery.js?ver=1.12.4:formatted:1485)
at HTMLDocument.K (jquery.js?ver=1.12.4:formatted:1497)

#560434

Okay it appears we need to make a minor change to wait for another event:

jQuery(document).on('js_event_wpv_addon_maps_init_map_completed', function() {
  var options = {'maxZoom': 13};
  WPViews.view_addon_maps.get_map('map-1').setOptions( options );
});

Please replace the code as shown above and let me know if you continue to see the error message.

#560561

Works.
Thanks Christian for your exellent support!