1

I use Leaflet to show a WMS Layer via a proxy.php (for authentication). That is working on most WMS Layers. But I have some WMS Sources, which are having a small shift in the tiles. See Overlay Map in the example.

Shift between WMS Tiles in Leaflet

<!DOCTYPE html>
TEST MAP
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<link rel="stylesheet" href="https://unpkg.com/leaflet@1.6.0/dist/leaflet.css" />
<script src="https://unpkg.com/leaflet@1.6.0/dist/leaflet.js"></script>
var map1  = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
    maxZoom: 30,
    maxNativeZoom: 18
});


var map4 = new L.tileLayer.wms("proxy.php?url=http://geoshop.kommunalportal.ch/SWMS?", {
    layers: 'lk_wms_wasser',
    format: 'image/png',
    transparent: true,
    maxZoom:30
});

var map = L.map('mapid').setView([47.549904, 9.152927], 18);

var baseMaps = {
    "map1": map1
    
};

var overlayMaps = {
    "map4": map4
};

L.control.layers(baseMaps, overlayMaps).addTo(map);

map1.addTo(map);
map4.addTo(map);
  • Welcome to Geographic Information Systems! Welcome to GIS SE! We're a little different from other sites; this isn't a discussion forum but a Q&A site. Your questions should as much as possible describe not just what you want to do, but precisely what you have tried and where you are stuck trying that. Please check out our short tour for more about how the site works. – Ian Turton Sep 21 at 15:07
  • what projection is your WMTS layer in? – Ian Turton Sep 21 at 15:07
  • I updated the question with code. So the Projection is standard from Leaflet. You can see the code in Action at: link – Marcel Sep 21 at 15:20
2

Standard projection for Leaflet is EPSG:3857. If you submit GetCapabilites request to you WMS server, you'll see that it supports only the following projections: EPSG:2056 and EPSG:21781.

This means two things:

  1. If you want to use this layer, you'll have to define on of those projections with proj4leaflet plugin and then use it for your layer and your map.
  2. Since Leaflet supports only one projection per map, you will not be able to combine this layer with OpenStreet layer, which has only EPSG:3857 projection.
| improve this answer | |
  • Thank's, you helped me a lot! I could manage it using proj4leaflet – Marcel Sep 23 at 12:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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