Using Leaflet I am trying to display a tiled raster layer described at the following url : https://mpt.svp.sk/server/rest/services/podkladove_mapy/orto_2019_12v/MapServer

I understood that the layer was not available in the web mercator projection EPSG:3857 from that server. So I have tried to display it in the original projection EPSG:102067 . My Leaflet map currently displays the layer tiles but at the wrong positions. Here is a Jsfiddle that demonstrates where I am standing: https://jsfiddle.net/uhcbpz73/

Here is the JS code I am using:

var crs = new L.Proj.CRS('EPSG:102067',
  '+proj=krovak +lat_0=49.5 +lon_0=24.83333333333333 +alpha=30.28813975277778 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +units=m +no_defs',
    resolutions: [
      529.1677250021168, 264.5838625010584, 132.2919312505292, 66.1459656252646, 26.458386250105836, 13.229193125052918, 6.614596562526459, 2.6458386250105836, 1.3229193125052918, 0.5291677250021167, 0.26458386250105836, 0.13229193125052918, 0.06614596562526459
    origin: [-600000.0,-1120000.00]

var map = new L.Map('map', {
    crs: crs
  }).setView([48.5, 19], 8);  

L.tileLayer('https://mpt.svp.sk/server/rest/services/podkladove_mapy/orto_2019_12v/MapServer/tile/{z}/{x}/{y}', {
  maxZoom: crs.options.resolutions.length-1,
  minZoom: 0,
  continuousWorld: true,
  • Just reverse {x} and {y} position in tile layer url.
    – TomazicM
    Commented May 29, 2020 at 11:14
  • Indeed thanks! It feels stupid and frustrating to have been so close and not being able to understand it completely. Would you mind giving some explanation on how to know that x and y had to be inverted? Also, is there any chance to add an OSM background layer or do I have to use something like mapproxy? Thanks!
    – Pierric
    Commented May 29, 2020 at 11:35
  • 1
    The answer for that is at e.g. mpt.svp.sk/server/sdk/rest/index.html#/Tile_Map/… - the syntax is /tilemap/<level>/<row>/<column> which translates to {z}/{y}/{x}, since the row number is the vertical y coordinate of the tile, and the column number is the horizontal x coordinate of the tile. Commented May 29, 2020 at 11:40
  • Thank you! Do you know if Mapproxy is the only way to go in case I want to use an OSM background layer?
    – Pierric
    Commented May 29, 2020 at 11:49


Your Answer

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

Browse other questions tagged or ask your own question.