I would like to center a pop-up on the marker where I click now it is moved to the right and above the marker.
I tried two methods:
Method 1:
var f = map.forEachFeatureAtPixel(
event.pixel,
function(ft, layer){return ft;}
);
var geometry = f.getGeometry();
var coord = geometry.getCoordinates();
content.innerHTML = featureStr;
overlay.setPosition(coord);
Method 2:
content.innerHTML = featureStr;
overlay.setPosition(getCenterOfExtent(extent));
function getCenterOfExtent(Extent){
var X = Extent[0] + (Extent[2]-Extent[0])/2;
var Y = Extent[1] + (Extent[3]-Extent[1])/2;
return [X, Y];
}
In both cases, the pop-up does not move.
Any other ideas?