The 3D position as a Vector3Tuple [x, y, z] in meters
The origin coordinates used as the reference point
Geographic coordinates (latitude, longitude, altitude)
It is the exact inverse of coordsToVector3: converting coordinates to a position and back returns the same coordinates, at any distance from the origin.
import { vector3ToCoords, coordsToVector3 } from '@wendylabsinc/react-three-map/maplibre';
const origin = { latitude: 51.5074, longitude: -0.1278 };
// Convert a 3D position back to coordinates
const position: Vector3Tuple = [100, 50, -200];
const coords = vector3ToCoords(position, origin);
// Returns { latitude: ~51.509, longitude: ~-0.126, altitude: 50 }
// Useful for getting coordinates after user interaction
const onDragEnd = (newPosition: Vector3Tuple) => {
const newCoords = vector3ToCoords(newPosition, origin);
console.log(`Moved to: ${newCoords.latitude}, ${newCoords.longitude}`);
};
coordsToVector3 for the forward operation
Converts a 3D position vector back to geographic coordinates.
This is the inverse operation of coordsToVector3.
The input Vector3Tuple should represent a position in meters where: