Last active
February 4, 2025 10:43
-
-
Save yuriinalivaiko/e2f190db749ba4445c40380fde4f1f00 to your computer and use it in GitHub Desktop.
This code snippet customizes the map zooming and bounds. Add this code to the functions.php file in the theme directory.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Restricting Map Bounds and Zoom. | |
*/ | |
add_action( 'wp_footer', function () { | |
?><script type="text/javascript"> | |
function um_user_locations_customize_03 ( args, hash, directory ) { | |
args.center = { | |
lat: 50, | |
lng: 15 | |
}, | |
args.restriction = { | |
latLngBounds: { | |
north: 71.4, | |
south: 29.4, | |
east: 40, | |
west: -10.5 | |
} | |
}; | |
args.zoom = 5; | |
args.minZoom = 4; | |
args.maxZoom = 9; | |
return args; | |
} | |
// customize the map in the member directory. | |
wp.hooks.addFilter( 'um_user_locations_map_args_init', 'um_user_locations', um_user_locations_customize_03 ); | |
// customize the map in profiles. | |
wp.hooks.addFilter( 'um_user_locations_map_field_args_init', 'um_user_locations', um_user_locations_customize_03 ); | |
</script><?php | |
}, 20 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This gist is a part of the article User Locations - Hooks.
Related article - Disabling Pan and Zoom.
You can add this code to the
functions.php
file in the active theme directory. Skip the opening<?php
tag.