Using qgis2web I created a Leaflet map that has a vector layer, a raster layer and OSM background. I included in the map the layer list ("Add layer list" option in qgis2web). The vector layer appears in the layer list and I can turn it on/off. However the raster layer does not appear in the list. Is that the intended behavior? Using OL3 I can turn rasters on/off.

  • 1
    Not intended behaviour, no, and I noticed the same just yesterday. I'll investigate and try to commit a fix. – Tom Chadwin Jan 27 '16 at 12:55

OK, this was a bug. I've committed a fix to the master branch on Github. If you download just the file leafletScriptStrings.py, and overwrite your copy, the bug should be gone. Do let us know.

  • Substituted the leafletScriptStrings.py but I got a python error. Not sure I substituted the file in some wrong way or if a new problem came up. Error is in pastebin.com/0m7V8Wnu – Daniel Jan 27 '16 at 15:34
  • Try overwriting the whole plugin - all the files. – Tom Chadwin Jan 27 '16 at 15:51
  • Substituting all the files did the trick. Plugin now works. But some other minor glitch appeared. When I export the map, in the layer list the Raster image is on top of the vector layer, even though in the map canvas, the vector is drawn on top of the raster. If I then turn off and on the raster layer, it is drawn on top of the vector file. – Daniel Jan 27 '16 at 16:08
  • There has been a lot of ink spilled on z-sorting of layers in Leaflet. In essence, you cannot depend on layer order. qgis2web does its best to retain it, but there are almost certainly situations in which the order is not as you require. That said, I would be interested in your example, as I've mainly concentrated on z-sorting of vector layers, so it's possible that rasters have missed out. Possibly, though, Leaflet dictates relative z-index of rasters and vectors. Maybe ask a new question with the details? – Tom Chadwin Jan 27 '16 at 16:21
  • I can open another question or, if you prefer, open a Github issue. I can also send the data over so you can test it. Let me know what works best – Daniel Jan 27 '16 at 17:09

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.