Maps SDK for Web
tt.MercatorCoordinate
A MercatorCoordinate object represents a projected three dimensional position. MercatorCoordinate uses the web mercator projection (EPSG:3857) with slightly different units: the size of 1 unit is the width of the projected world instead of the "mercator meter" the origin of the coordinate space is at the north-west corner instead of the middle For example, MercatorCoordinate(0, 0, 0) is the north-west corner of the mercator world and MercatorCoordinate(1, 1, 0) is the south-east corner. If you are familiar with vector tiles it may be helpful to think of the coordinate space as the 0/0/0 tile with an extent of 1. The z dimension of MercatorCoordinate is conformal. A cube in the mercator coordinate space would be rendered as a cube.
Constructor
tt.MercatorCoordinate(x, y, [z=0])
Methods
fromLngLat(lngLat, [altitude=0]): Maps.MercatorCoordinate Static
Project a LngLat to a MercatorCoordinate.
Example
var coord = tt.MercatorCoordinate.fromLngLat({ lng: 0, lat: 0}, 0);
coord; // MercatorCoordinate(0.5, 0.5, 0)
Parameters
Name | Description |
---|---|
lngLat
Maps.LngLat default:None |
The location to project. |
altitude
Number default:0 |
The altitude in meters of the position. |
Returns
The projected mercator coordinate.
toAltitude( ): Number
Returns the altitude in meters of the coordinate.
Example
var coord = new tt.MercatorCoordinate(0, 0, 0.02);
coord.toAltitude(); // 6914.281956295339
Returns
The altitude in meters.
toLngLat( ): Maps.LngLat
Returns the LngLat for the coordinate.
Example
var coord = new tt.MercatorCoordinate(0.5, 0.5, 0);
var latLng = coord.toLngLat(); // LngLat(0, 0)
Returns
The LngLat object