wpgmp_map_tile_url - WP Maps Pro

15000+ live websites are using this google maps wordpress plugin.

wpgmp_map_tile_url

This hook in the WP Maps Pro plugin allows developers to customize the URL of map tiles for Leaflet-based maps. It is triggered when the map tiles are being set up, allowing for the modification of the default map tile URL.

Usage

Developers can implement this hook by adding a filter in their theme’s functions.php file or a custom plugin. It is particularly useful for changing the map tile source to a different provider or implementing self-hosted tiles for improved performance or styling.

Example 1

Changing the map tile URL to use a different tile provider, such as Mapbox.

add_filter( 'wpgmp_map_tile_url', function( $tile_url, $map ) {
    return 'https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}';
}, 10, 2 );

Example 2

Using self-hosted map tiles for a custom look and feel.

add_filter( 'wpgmp_map_tile_url', function( $tile_url, $map ) {
    return 'https://mywebsite.com/tiles/{z}/{x}/{y}.png';
}, 10, 2 );

Example 3

Switching to a different OpenStreetMap server to reduce load on the default server.

add_filter( 'wpgmp_map_tile_url', function( $tile_url, $map ) {
    return 'https://{s}.tile.openstreetmap.de/{z}/{x}/{y}.png';
}, 10, 2 );

Tip: When modifying map tile URLs, always ensure you comply with the service provider’s terms of use and handle any required API keys securely. Avoid exposing sensitive information in your code.

Install Plugin Now!

Buy this plugin exclusively on CodeCanyon! You’ll get free updates, full support, and if you’re not satisfied, we’ve got you covered with a 30-day money-back guarantee.