Skip Navigation

[Resolved] Changing the zoom level via JS

This support ticket is created 5 years, 4 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 2 replies, has 2 voices.

Last updated by sachaB 5 years, 4 months ago.

Assisted by: Minesh.

Author
Posts
#1155174

Tell us what you are trying to do?
I'm trying to change the zoom level of a map via JS

Is there any documentation that you are following?
https://toolset.com/documentation/user-guides/programmatically-change-map-settings/

Is there a similar example that we can see?

What is the link to your site?
hidden link

This code works, except for the line with the note:

// Listen to js_event_wpv_addon_maps_init_map_completed
$( document ).on('js_event_wpv_addon_maps_init_map_completed', function( event, event_settings ) {
// Get the map using our .get_map() method
var map = WPViews.view_addon_maps.get_map( event_settings.map_id );
// Use Maps API .setOptions() method to programmatically change any option on the map.
if ( map ) {
map.setOptions({
gestureHandling: 'none',
});
map.setZoom(4); <------- NOT WORKING
}
} );

Am I doing something wrong? Every set in "setOption" is working correctly

Thanks

#1155244

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - could you please try to use following code:

jQuery(document).on('js_event_wpv_addon_maps_init_map_completed', function() {

// Get the map using our .get_map() method
var map = WPViews.view_addon_maps.get_map( event_settings.map_id );
// Use Maps API .setOptions() method to programmatically change any option on the map.
if ( map ) {

map.setOptions({
gestureHandling: 'none',
'maxZoom': 4,
});

}

});
#1155648

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.