0

When I add two layers to a Leaflet map (a basemap and a Geoserver WMS), the basemap disappers. But when its tiling, it can be seen for a moment.

What's the problem? Maybe it's due to the transparency or to the zIndex?

This is the basemap (OSM)

L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
        attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors',
        zIndex: 2
    }).addTo(map);

and this is the Geoserver WMS

var wmsLayer = L.tileLayer.wms('http://188.213.174.15:8080/geoserver/wms?', {
    layers: 'varymaps:badacstur',
    transparent: true,
    zIndex: 1
}).addTo(map);
1

You are giving a zIndex to the basemap with a superior value than the WMS layer, my guess is that's what causing this problem, you should invert the z-indexes

basemap : zIndex: 1;

WMS layer: zIndex: 2;

1

If you're not specifying a format option in your L.TileLayer.WMS, the default of JPEG format is used - a image format that does not support transparency.

  • I used format: 'image/png', transparent: true, – Hadh Jul 14 '16 at 12:06

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.