Problem:
The client wanted to change the zoom accordingly the results of the View. If it doesn't return any results, then the zoom should be different.
Solution:
1. Call the map render as last thing in the layout
2. Add your default marker inside of the no posts found shortcode
3. Just like this:
[wpv-layout-start] [wpv-items-found] <!-- wpv-loop-start --> <ul class="wpv-loop js-wpv-loop"> <wpv-loop> <li>[wpv-post-body view_template="Loop item in posts"]</li> [wpv-map-marker map_id='map-4' marker_id='marker-[wpv-post-id]' marker_field='wpcf-address-test'][/wpv-map-marker] </wpv-loop> </ul> <!-- wpv-loop-end --> [/wpv-items-found] [wpv-no-items-found] [wpv-map-marker map_id='map-4' marker_id='marker-[wpv-post-id]' address='Rua Pedro Trogo - Santo Antônio, Juiz de Fora - State of Minas Gerais, Brazil'][/wpv-map-marker] [/wpv-no-items-found] [wpv-map-render map_id='map-4' marker_icon='http://localhost:8888/teste/wp-content/plugins/views-addon-maps/resources/images/markers/Buildings.png'] [wpv-layout-end]
Now use a Views JavaScript front-end event to change the zoom dynamically:
jQuery( document ).on( 'js_event_wpv_addon_maps_init_map_started', function( event, data ) { if (WPViews.view_addon_maps.maps_data[0].markers[0].marker == 'marker-123'){ data.map_options.single_zoom = 1; } });
First you will need to define an ID for your marker in the wpv-map-marker shortcode inside of no items found. Then use the same ID in the code above and your zoom can be adjusted.
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 |
---|---|---|---|---|---|---|
- | 8:00 – 17:00 | 8:00 – 17:00 | 8:00 – 17:00 | 8:00 – 17:00 | 8:00 – 17:00 | - |
- | - | - | - | - | - | - |
Supporter timezone: America/Sao_Paulo (GMT-03:00)
This topic contains 5 réponses, has 2 voix.
Last updated by Adriano Il y a 7 années et 9 mois.
Assisted by: Adriano.