Name | Type | Description |
---|---|---|
x |
number | The x component of the position. |
y |
number | The y component of the position. |
z |
number | The z component of the position. |
- [Example: Add a custom style layer](https://www.mapbox.com/mapbox-gl-js/example/custom-style-layer/)
Example:
const nullIsland = new mapboxgl.MercatorCoordinate(0.5, 0.5, 0);
See:
Methods
-
staticSuperMap3D.MercatorCoordinate.fromLngLat(lngLatLike, altitude) → MercatorCoordinate
-
Project a `LngLat` to a `MercatorCoordinate`.
Name Type Default Description lngLatLike
LngLatLike The location to project. altitude
number 0
The altitude in meters of the position. Returns:
The projected mercator coordinate.Example:
const coord = mapboxgl.MercatorCoordinate.fromLngLat({lng: 0, lat: 0}, 0); console.log(coord); // MercatorCoordinate(0.5, 0.5, 0)
-
Returns the distance of 1 meter in `MercatorCoordinate` units at this latitude. For coordinates in real world units using meters, this naturally provides the scale to transform into `MercatorCoordinate`s.
Returns:
Distance of 1 meter in `MercatorCoordinate` units.Example:
// Calculate a new MercatorCoordinate that is 150 meters west of the other coord. const coord = new mapboxgl.MercatorCoordinate(0.5, 0.25, 0); const offsetInMeters = 150; const offsetInMercatorCoordinateUnits = offsetInMeters * coord.meterInMercatorCoordinateUnits(); const westCoord = new mapboxgl.MercatorCoordinate(coord.x - offsetInMercatorCoordinateUnits, coord.y, coord.z);
-
Returns the altitude in meters of the coordinate.
Returns:
The altitude in meters.Example:
const coord = new mapboxgl.MercatorCoordinate(0, 0, 0.02); coord.toAltitude(); // 6914.281956295339
-
toLngLat() → LngLat
-
Returns the `LngLat` for the coordinate.
Returns:
The `LngLat` object.Example:
const coord = new mapboxgl.MercatorCoordinate(0.5, 0.5, 0); const lngLat = coord.toLngLat(); // LngLat(0, 0)