Backend for Custom Frontend OSPRO Surveyor Indonesia
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
834 B

import { store } from "../appredux/store";
export const removeLayerByName = (layerName) => {
const {mymap} = store.getState().mapReducer;
var layerToRemove = [];
mymap.eachLayer(function(layer) {
if (layer.wmsParams) {
if (layer.wmsParams.layers) {
let layerWmsName = layer.wmsParams.layers.split(':')[1];
if (layerName === layerWmsName) {
layerToRemove.push(layer)
}
}
}
else {
if (layer.options && layer.options.name && layer.options.name === layerName) {
layerToRemove.push(layer);
}
}
});
if (layerToRemove.length > 0) {
for (let i = 0; i < layerToRemove.length; i++) {
mymap.removeLayer(layerToRemove[i]);
}
}
}