5

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.

1

2 Answers 2

4

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);
3
  • 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
  • have you added it to the map with addTo()? Commented Jan 21, 2016 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.
    – Sergio Tx
    Commented Apr 5, 2017 at 14:04
2

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.

1
  • True! Unfortunately we can't all be using geoserver all the time.....sad times.
    – nr_aus
    Commented Oct 13, 2021 at 2:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.