I would like to start using Leaflet instead of OpenLayers, but I can't find a way to load WMTS layer into the map. Is that possible with Leaflet, or do I have to stick with OL? I haven't found anything related to this topic.
2 Answers
Technically wmts could be use as a tilelayer, but will have to figure out your Tiling structure. A constructor for a layer could look something like this:
L.tileLayer('<ServiceRoot>?SERVICE=WMTS&REQUEST=GetTile&VERSION=[version]&Layer=[layername]&Format=image/png&TileMatrixSet[MatrixsetName]=&TileMatrix={z}&TileRow={x}&TileCol={y}').addTo(map);
-
Hi, thanks for a hint, I've tried
var zm = L.tileLayer('http://geoportal-zm0.cuzk.cz/WMTS_ZM/service.svc/get?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&Layer=zm&TileMatrixSet=openlayerssphericalmercator:epsg:900913&TILEMATRIX={z}&TILEROW={x}&TILECOL={y}&FORMAT=image/png');
with no success. No request is being sent to the server. But if I visit wmts directly, it works. Commented Jan 15, 2013 at 13:01 -
-
this worked for me with a couple of fixes: col is the X and row is the Y and TileMatrixSet has the equals sign after the parameter here. Commented Apr 5, 2017 at 14:04
You don't really need to use WMTS, if you're reading from GeoServer. GeoServer does the same caching for both WMTS and WMS, so just using a Leaflet WMS reader will work fine.
-
True! Unfortunately we can't all be using geoserver all the time.....sad times.– nr_ausCommented Oct 13, 2021 at 2:03