I have a map that works perfectly, not that this is a problem, but when I switch layers with popup triggered, the popup disappears, I would like to know if there is something possible for it to stay open when another layer is loaded. Or get the click coordinates to call again, something like that. This is part of my code where I call the popup;
var container = document.getElementById('popup');
var content = document.getElementById('popup-content');
var closer = document.getElementById('popup-closer');
/**
* Create an overlay to anchor the popup to the map.
*/
var overlay = new ol.Overlay({
element: container,
autoPan: true,
autoPanAnimation: {
duration: 250
}
});
let zoomMapInit = 5;
if ($(document).width() <= 768) {
zoomMapInit = 4;
chartWidth = 200, chartHeight = 100;
showZoomMap = false;
}
const view = new ol.View({
projection: 'EPSG:4326',
center: [-54.672122, -13.746438],
zoom: zoomMapInit
});
const map = new ol.Map({
target: 'map',
layers: [new ol.layer.Tile({
source: new ol.source.OSM({
attributions: [
'© <a href="http://www.i3gs.org/" target="_blank">i3GS</a> | ',
ol.source.OSM.ATTRIBUTION
],
})
}), switcherLayersGroupBiomas, switcherLayersGroupCamadas],
overlays: [overlay],
controls: ol.control.defaults({
zoom: showZoomMap,
}),
view: view
});
const layerSwitcher = new ol.control.LayerSwitcher({
tipLabel: 'Layers',
groupSelectStyle: 'children',
collapse: false,
});
map.addControl(layerSwitcher);
addNewUniqueLayer(geoserverGetLayerHome());
map.on('singleclick', function (event) {
overlay.setPosition(undefined);
currentYearValue = '';
insertChart(event);
cleanMunicipio();
$("#map").click();
});