Used built in functions to calculate popup pos

feature.geometry.getBounds().getCenterLonLat()