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"
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.
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.
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.
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?
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.
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.
Your last comment, understanding is fully correct. That would work fine for me.
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)
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)
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.
Works.
Thanks Christian for your exellent support!