I try to remove selection of the layer when using a mouse click on new area.
So there is on lick functionality on the layer
layer.on({
click: (event) => {
event.target.setStyle({
color: "black",
weight: 1.5,
});
},
});
And when I click on new area, I just get 2 areas with such border, but need only to select new one, and remove previous. Can anybody help with that?
Here is the code how I use geoJSON
<MapContainer center={getCenter()} zoom={getZoom()}>
<GeoJSON
ref={geoJSON}
center={getCenter()}
zoom={getZoom()}
style={setColor}
data={germanyDis}
onEachFeature={onEachArea}
/>
</MapContainer>
And here is my onEachArea
function
const onEachArea = (area, layer) => {
layer.on({
click: (event) => {
event.target.setStyle({
color: "black",
weight: 1.5,
});
event.target.bringToFront();
},
});