I came back to this problem after a year and what I did. First of all this problem is related only to iOS, on Android position property is presented and valid.
Next my code:
const ratio = PixelRatio.get();
const {northEast, southWest} = await mapRef.current?.getMapBoundaries();
const longitudeDelta = northEast.longitude - southWest.longitude;
mapContainerRef.current?.measureInWindow((x, y, w, h) => {
const coord = convertGeoToPixel(
coordinate.latitude,
coordinate.longitude,
w,
h,
southWest.longitude,
longitudeDelta,
southWest.latitude,
(southWest.latitude * Math.PI) / 180,
);
setCoords({
left: coord.x * ratio,
top: coord.y * ratio,
});
});
Where convertGeoToPixel
is a function from this answer about Mercator projection https://stackoverflow.com/a/27313080
function convertGeoToPixel(
latitude,
longitude,
mapWidth, // in pixels
mapHeight, // in pixels
mapLonLeft, // in degrees
mapLonDelta, // in degrees (mapLonRight - mapLonLeft);
mapLatBottom, // in degrees
mapLatBottomDegree,
) {
// in Radians
var x = (longitude - mapLonLeft) * (mapWidth / mapLonDelta);
latitude = (latitude * Math.PI) / 180;
var worldMapWidth = ((mapWidth / mapLonDelta) * 360) / (2 * Math.PI);
var mapOffsetY =
(worldMapWidth / 2) *
Math.log(
(1 + Math.sin(mapLatBottomDegree)) / (1 - Math.sin(mapLatBottomDegree)),
);
var y =
mapHeight -
((worldMapWidth / 2) *
Math.log((1 + Math.sin(latitude)) / (1 - Math.sin(latitude))) -
mapOffsetY);
return {x: x, y: y};
}
So convertGeoToPixel
returns coordinates of the marker relative to the map view