web_mercator library




DEFAULT_ALTITUDE → const double
Mapbox default altitude
Average circumference (40075 km equatorial, 40007 km meridional)
PI_2 → const double
pi * .5
PI_4 → const double
pi * .25
TILE_SIZE → const int
Default size of a map tile


addMetersToLngLat(Vector3 lngLatZ, Vector3 xyz) Vector3
Offset a lngLatZ position by meterOffset (northing, easting) xyz.
bbox(List<List<double>> coordinates) List<double>
Takes a list of coordinates and returns a bounding box enclosing them (in minX, minY, maxX, maxY order). see: https://github.com/Turfjs/turf/blob/master/packages/turf-bbox/index.ts
destination(double lng, double lat, {num distance, num bearing = 0}) Vector2
Takes a lng, lat location and calculates the location of a destination point given a distance in kilometers; and bearing in degrees. see: https://github.com/Turfjs/turf/blob/master/packages/turf-destination/index.ts
fitBounds({num width, num height, List<num> bounds, double minExtent = 0, double maxZoom = 24, dynamic padding = 0, List<num> offset = const [0, 0]}) Map<String, num>
Returns map settings {lng, lat, zoom} containing the provided bounds within the provided width & height. Only supports non-perspective mode.
getDistanceScales(double lng, double lat, {bool highPrecision = false}) Map<String, List>
Calculate distance scales in meters around current lat, lng, for both degrees and pixels.
getMeterZoom(double lat) double
Return the zoom level that gives a 1 meter pixel at a certain lat.
getProjMatrix({num width, num height, double pitch, double altitude, double nearZMultiplier, double farZMultiplier}) Matrix4
getProjParameters(num width, num height, {double altitude = DEFAULT_ALTITUDE, double pitch = 0, double nearZMultiplier = 1, double farZMultiplier = 1}) Map<String, num>
Calculates camera projection for
getViewMatrix({num height, double pitch, double bearing, double altitude, double scale, Vector2 center}) Matrix4
lengthToRadians(num distance) num
Convert a distance measurement (assuming a spherical Earth) from a real-world unit into radians. see: https://github.com/Turfjs/turf/blob/master/packages/turf-helpers/index.ts
lngLatToWorld(double lng, double lat) Vector2
Project lng, lat on sphere on 512*512 Mercator Zoom 0 tile.
log2(num x) num
perspective({double fovy, double aspect, double near, double far}) Matrix4
Generates a perspective projection matrix with the given bounds. see: gl-matrix/mat4.js
pixelsToWorld(Vector3 xyz, Matrix4 pixelUnprojMatrix, {double targetZ}) Vector
Unproject xyz pixels on screen to flat coordinates given the pixelUnprojMatrix.
scaleToZoom(double scale) num
transformVector(Vector4 vector, Matrix4 matrix) Vector4
Transforms a vector with a projection matrix.
worldToLngLat(double x, double y) Vector2
Unproject world point x, y on map onto lng, lat on sphere.
worldToPixels(Vector3 xyz, Matrix4 pixelProjMatrix) Vector4
Project flat coordinates xyz to pixels on screen given the pixelProjMatrix.
zoomToScale(double zoom) num