mcguffin / acf-openstreetmap-field

WordPress ACF Field for OpenStreetMap
https://wordpress.org/plugins/acf-openstreetmap-field/
GNU General Public License v3.0
107 stars 21 forks source link

Use MapTiler Cloud raster tile layers? #38

Closed SRUC closed 4 years ago

SRUC commented 4 years ago

Would it be possible to add support for MapTiler Cloud raster tile layers https://www.maptiler.com?

Thanks, David

mcguffin commented 4 years ago

Hi, The plugin is including Leaflet Providers extension which contains all the providers for the plugin. (My time does not allow me to researching and maintain a provider list, so I added this as a dependecy.) The most sustainable way would be to place your request there. (The developer seems to be very fond of pull request)

To get it fixed quickly for you, there is a filter named acf_osm_leaflet_providers, allowing you to add whatever map layer provider you desire.

Something like this should do it:

add_filter('acf_osm_leaflet_providers', function( $providers ) {
    $providers['MapTiler'] = [
        'url' => 'https://{s}.tiles.some.domain.tld/map/{z}/{x}/{y}.png?access_key=abcd1234567890',
        'options' => [
            'attribution' => '© The most generic map tile provider ever',
        ],
    ];
    return $providers;
});

All Provider definitions extracted from the Leaflet Providers extension. https://github.com/mcguffin/acf-openstreetmap-field/blob/master/etc/leaflet-providers.json (can be quite complex!)

SRUC commented 4 years ago

Thanks Jörn, that's really helpful - much appreciated.