I am trying to add a custom view on the map in react application which will handle the visibility of some of the layers. This view needs to be removed or hide at some condition and then needs to be added again.
I have used the code like below :
// code to add the custom view
displayLayerTypeSwitcher() {
const checkBoxElement = document.getElementById('FieldCheckboxDetails');
if (checkBoxElement) {
if (this.mapView?.ui.find('FieldCheckboxDetails')) {
this.mapView?.ui.remove('FieldCheckboxDetails');
}
this.mapView?.ui.add(checkBoxElement, "top-right");
}
}
// code to remove the custom view removeLayerTypeSwitcherView() {
const checkBoxElement = document.getElementById('FieldCheckboxDetails');
if (checkBoxElement) {
if (this.mapView?.ui.find('FieldCheckboxDetails')) {
this.mapView?.ui.remove(checkBoxElement);
}
}
}
but once i invoke the "removeLayerTypeSwitcherView" method, the custom view is not avaialble anymore to be readded . It seems like it is removed from the DOM permanently.
Could anybody suggest how can i acheieve the functionality to show/hide a custom view on a map.