leaflet wms change source data

119 views
Skip to first unread message

Leno Arkhi

unread,
Jul 28, 2021, 4:06:35 PM7/28/21
to Leaflet
hello, everyone.
I have a 2 questions.
1. The first one.
i have 2 wms layers. and 2 L.WMS.source. In popup informations looks like this: 

Results for FeatureType 'http://mapserver.cepl.rssi.ru:8080/geoserver/CFO:map_cfo_2014': -------------------------------------------- PALETTE_INDEX = 9.0 --------------------------------------------

I need change every number to the name. for example 9.0=> forest, 7.0=> lakes, 5.0=> sities. and remove text PALETTE_INDEX. How can i do this, any way? thanks a lot. 

2. And second questions. I have 2 wms layers and 2  L.Wms.source. How can I do this situation- when 1 layer is off and his source will off. 

my code is simply:
var layer1 = new L.tileLayer.wms("http://mapserver.cepl.rssi.ru:8080/geoserver/CFO/wms", {
layers: "CFO:map_cfo_2010",
version: '1.1.0',
name: "map_cfo_2010",
// format: 'application/openlayers',
format: 'image/png',
transparent: true,
crs: L.CRS.EPSG4326
// attribution: "DIRECCION GENERAL DEL CATASTRO"
}).addTo(map);


var layer2 = new L.tileLayer.wms("http://mapserver.cepl.rssi.ru:8080/geoserver/CFO/wms", {
layers: "CFO:map_cfo_2014",
version: '1.1.0',
name: "map_cfo_2014",
// format: 'application/openlayers',
format: 'image/png',
transparent: true,
crs: L.CRS.EPSG4326
// attribution: "DIRECCION GENERAL DEL CATASTRO"
}).addTo(map);

opacity: 0.1,
});
source1.getLayer("CFO:map_cfo_2010").addTo(map);


opacity: 0.1,
});
source2.getLayer("CFO:map_cfo_2014").addTo(map);

var overlayMaps = {
"Map CFO 2010": layer1,
"Map CFO 2014": layer2
};
L.control.layers(baseMaps, overlayMaps).addTo(map);

I need - layer1 -off => layer1 and source1 off
layer2 on=> layer2 and source2 on

thanks a lot. i hope its clear what i mean... 

Mark Lawton

unread,
Jul 28, 2021, 4:09:30 PM7/28/21
to leafl...@googlegroups.com
you can add layers using
map.addLayer

you can remove layers using
map.removeLayer


--

---
You received this message because you are subscribed to the Google Groups "Leaflet" group.
To unsubscribe from this group and stop receiving emails from it, send an email to leaflet-js+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/leaflet-js/11c849fc-7e04-423d-a159-b44d3927cff6n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages