In short, I need layer groups to be controlled using the elevator control, two or three at a time. In this JSFiddle, when changing basemaps, the hydrographic overlay should always remain on top of various basemaps.
If you start and use the color control in the upper right corner, you will notice how hydrodetection will be disabled when you switch to images and stay if you do not switch to topographic and back to national geography. This is the behavior that I was able to reliably reproduce. If you play with him, you can see some rather strange stuff.
Any input or suggestions on the best ways to achieve this are welcome. To solve this problem, it is necessary to use a level control to switch the base card, while maintaining waterproofing from above. Otherwise, I am completely open to alternative solutions.
If you're curious before moving on to JSFiddle , here is the JavaScript ...
var map = L.map('map', {
center: [45.7067, -121.5217],
zoom: 7
});
var hydro = L.esri.tiledMapLayer('http://hydrology.esri.com/arcgis/rest/services/WorldHydroReferenceOverlay/MapServer');
var nationalGeographic = L.layerGroup([
hydro,
L.esri.basemapLayer('NationalGeographic')
]),
esriTopo = L.layerGroup([
hydro,
L.esri.basemapLayer('Topographic')
]),
esriShadedRelief = L.layerGroup([
L.esri.tiledMapLayer('ShadedReliefLabels'),
hydro,
L.esri.basemapLayer('ShadedRelief')
]),
esriImagery = L.layerGroup([
hydro,
L.esri.basemapLayer('Imagery')
]);
map.addLayer(esriTopo);
var baseLayers = {
"National Geographic": nationalGeographic,
"Esri Topographic": esriTopo,
"Shaded Relief": esriShadedRelief,
"Imagery": esriImagery
};
var controlLayers = L.control.layers(baseLayers).addTo(map);
source
share