Reputation: 21
I have three base layers in a layer group
var baseLayers = {"Straßenkarte": osmLayer, "Luftbild": bingLayer, "Luftbild mit Straßennamen": bingLabelLayer};
makes my control. After
L.control.layers(baseLayers).addTo(map)
the last layer metioned there is shown on top. I can draw another layer on top with zIndex or for example
bingLayer.bringToFront()
But in this case, the layer marked in the control does not change. How can I alter this (sorry, leaflet-dummy)?
Upvotes: 0
Views: 101
Reputation: 53185
Welcome to SO!
What you have probably missed is that the visibility of your basemaps should be modified by directly adding them to / removing them from the map, instead of fiddling with their z-index / DOM position with bringToFront.
Then the Leaflet Layers Control automatically syncs its selection when you programmatically add / remove Layers it knows.
Upvotes: 0