Looks like there’s a plugin for it: https://github.com/mylen/leaflet.TileLayer.WMTS
As a rule, I’ve been avoiding adding plugins to my plugin (difficult to maintain, and I feel like I’d be taking credit for their work). But you should be able to customize your site with some amount of effort.
You could add a new shortcode :
add_shortcode('leaflet-wmts', array(&$this, 'wmts_shortcode'));
Register (and enqueue) the wmts js library:
wp_register_script('leaflet_wmts_js', '/leaflet-tilelayer-wmts.js', Array(), $version, true);
And basically copy/edit the map_shortcode
script:
wp_enqueue_script('leaflet_wmts_js');
$content = '<div id="leaflet-wordpress-map-'.$leaflet_map_count.'" class="leaflet-wordpress-map" style="height:'.$height.'; width:'.$width.';"></div>';
$content .= "<script>
WPLeafletMapPlugin.add(function () {
var map,
baseURL = '{$tileurl}',
base = new L.TileLayer.WMTS( baseURL ,
{
layer: 'GEOGRAPHICALGRIDSYSTEMS.MAPS.SCAN-EXPRESS.STANDARD',
style: 'normal',
tilematrixSet: 'PM',
format: 'image/jpeg',
attribution: '<a href=\'https://github.com/mylen/leaflet.TileLayer.WMTS\'>GitHub</a>© <a href=\'https://www.ign.fr\'>IGN</a>'
}
);
map = L.map('leaflet-wordpress-map-{$leaflet_map_count}',
{
layers: [base],
zoomControl: {$zoomcontrol},
scrollWheelZoom: {$scrollwheel}
}).setView([{$lat}, {$lng}], {$zoom});";
…etc.
Then your shortcode could be [leaflet-wmts tileurl="tile-url-here.com"]
.