how to display a popup with the appropriate position?
map.on('singleclick', function (evt) {
overlayPopup.setPosition(undefined);
closer.blur();
var features = [];
var layers = [];
var feature = map.forEachFeatureAtPixel(evt.pixel, function (feature, layer) {
features.push(feature);
layers.push(layer);
});
if (layers[0] == Layer1Popup) {
showLayer1Popup(features);
}
});
function showLayer1Popup(features) {
feature = features[0];
var coord = feature.getGeometry().getCoordinates();
if (feature) {
content.innerHTML = '<b>Name : ' + feature.get('name') + '</b><br><br>Phone: ' + feature.get('phone');
overlayPopup.setPosition(coord);
}
}