-
Notifications
You must be signed in to change notification settings - Fork 22
Custom Mapbox
Jörn Lund edited this page Aug 17, 2024
·
1 revision
-
Open your map in mapbox studio.
-
Share
-
In the Modal Dialog choose "Developer Resources > Third Party". Make shure 'WMTS' is selected in the dorpdown and copy the URL.
-
Open it in a browser. Find the XML Node named
<ResourceUrl>
and copy thetemplate
attribute. Value should be something likehttps://api.mapbox.com/styles/v1/podpirate/XXXX/tiles/{TileMatrix}/{TileCol}/{TileRow}?access_token=XXXX
-
Replace strings like this
{TileMatrix}
=>{z}
,{TileCol}
=>{x}
,{TileRow}
=>{y}
. Result:https://api.mapbox.com/styles/v1/podpirate/XXXX/tiles/{z}/{x}/{y}?access_token=XXXX
-
In PHP hook into
acf_osm_leaflet_providers
and add a new leaflet provider:
add_filter('acf_osm_leaflet_providers', function( $providers ) {
$providers['MyMapbox'] = [
'url' => 'https://api.mapbox.com/styles/v1/podpirate/XXXX/tiles/{z}/{x}/{y}?access_token=XXXX', // <== The result from step 5
'options' => [
'attribution' => '© <a href="https://www.mapbox.com/about/maps/" target="_blank">Mapbox</a> {attribution.OpenStreetMap} <a href="https://www.mapbox.com/map-feedback/" target="_blank">Improve this map</a>',
'tileSize' => 512,
'maxZoom' => 18,
'zoomOffset' => -1,
],
];
} );
- Voilá, your Custom Mapbox style: