alexandre-melard / leaflet.TileLayer.WMTS

Add WMTS layering for leaflet
Other
78 stars 84 forks source link

Couldn't publish WMTS for neither 4326 nor 900913 #18

Open kanerlevent opened 6 years ago

kanerlevent commented 6 years ago

I am trying to add the default WMTS Italy mosaic that can be found in GeoServer by default (nurc:mosaic, namely) to my map via Leaflet by tweaking the code shared here. I get the WMTS link by simply right clicking on GeoServer's Web Admin page WMTS 1.0.0 and copy the link location. Here it is: http://localhost:8081/geoserver/gwc/service/wmts?REQUEST=GetCapabilities And here is my code:

// The WMTS URL var url = "http://localhost:8081/geoserver/gwc/service/wmts?REQUEST=GetCapabilities";

var italy = new L.TileLayer.WMTS( url , { layer: 'nurc:mosaic', style: "", tilematrixSet: "EPSG:900913", format: "image/png" } ); var map = L.map('map').setView([37, 24], 4);

L.control.scale({'position':'bottomleft','metric':true,'imperial':false}).addTo(map);

var osm = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { attribution: '© OpenStreetMap' }).addTo(map);

var baseLayers = { "ItalyWMTS" : italy, "OpenStreetMap": osm };

L.control.layers(baseLayers).addTo(map);

It didn't work.

I also checked if the nurc:mosaic has the EPSG:900913 defined, it has. ( I checked it from the GeoServer's Web Admin Page - Tile Layers - Tile Caching - Gridset, there are gridsets for both EPSG 4326 and EPSG 900913). I couldn't manage to get it work with 4326 too

zigacernigoj commented 6 years ago

It's because the rows and columns are computed differently. You would want to check if it is EPSG:4326 and compute rows and cols the way that is described here.

I will try it "tomorrow" and will tell if it's doable.