I have a standalone geowebcache, I want to use it to serve wmts to a leaflet map but I find it hard to understand what url to use.
Displaying the layers in QGIS work fine when I add the server using the url http://localhost:8080/geowebcache/service/wmts/
But how do I find out what the url should be for leaflet?
If I check getCapabilities i find http://localhost:8080/geowebcache/service/wmts/rest/test_layer/{style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}?format=image/png
But how do I implement that?
I am using default style. I have created a custom TileMatrixSet called "EPSG:3857"
I tried this without luck
L.tileLayer('http://localhost:8080/geowebcache/service/wmts/rest/test_layer/EPSG:3857/{z}/{y}/{x}?format=image/png')
Previously I have successfully displayed layers in leaflet using tms from geoserver using the structure below, but for some reason i get 400 error now.
L.tileLayer('http://localhost:8080/geowebcache/service/tms/1.0.0/test_layer@EPSG:3857@jpeg{z}/{x}/{-y}.jpeg')
Really scratching my head here because I try to understand where I should look and and how I can implement this properly? Is it possibly to use wmts with leaflet? I found a wmts plugin for leaflet https://github.com/alexandre-melard/leaflet.TileLayer.WMTS but is that really the only/recommended way to do it?
EDIT: This url is working L.tileLayer('http://localhost:8080/geowebcache/service/wmts?layer=test_layer&style=&tilematrixset=EPSG:3857&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image/jpeg&TileMatrix=EPSG:3857:{z}&TileCol={x}&TileRow={y}')
But I dont understand how I can get there from looking at getCapabilities alone? I found out by looking in the network tab for from geowebcache/demo. But how I know how to from `
http://localhost:8080/geowebcache/service/wmts/rest/test_layer/{style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}?format=image/png
to
http://localhost:8080/geowebcache/service/wmts?layer=test_layer&style=&tilematrixset=EPSG:3857&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image/jpeg&TileMatrix=EPSG:3857:{z}&TileCol={x}&TileRow={y}
that I dont understand?
{style}
parameter in your WMTS url, which is usuallydefault
. There should be also{z}
instead of first{y}
.