LngLat

A LngLat object represents a given longitude and latitude coordinate, measured in degrees.
These coordinates are based on the WGS84 (EPSG:4326) standard.

Nextbillion GL uses longitude, latitude coordinate order (as opposed to latitude, longitude) to match the
GeoJSON specification.

Note that any Nextbillion GL method that accepts a LngLat object as an argument or option
can also accept an Array of two numbers and will perform an implicit conversion.
This flexible type is documented as LngLatLike .

Constructor

Name
LngLat

new LngLat(lng: number, lat: number)


Parameters


  1. lng: number
  2. lat: number

Methods

Method
distanceTo

distanceTo(lngLat: LngLat)


Parameters


  1. lngLat: LngLat

Return Value: number


Returns the approximate distance between a pair of coordinates in meters
Uses the Haversine Formula (from R.W. Sinnott, "Virtues of the Haversine", Sky and Telescope, vol. 68, no. 2, 1984, p. 159)
toArray

toArray()



Return Value: none


Returns the coordinates represented as an array of two numbers.
toBounds

toBounds(radius: number)


Parameters


  1. radius: number

Return Value: LngLatBounds


Returns a LngLatBounds from the coordinates extended by a given radius . The returned LngLatBounds completely contains the radius .
toString

toString()



Return Value: string


Returns the coordinates represent as a string.
wrap

wrap()



Return Value: LngLat


Returns a new LngLat object whose longitude is wrapped to the range (-180, 180).
convert

convert(input: LngLatLike)


Parameters


  1. input: LngLatLike

Return Value: LngLat


Converts an array of two numbers or an object with lng and lat or lon and lat properties
to a LngLat object.

If a LngLat object is passed in, the function returns it unchanged.

Example

1
var ll = new nextbillion.maps.LngLat(-123.9749, 40.7736);
2
ll.lng; // = -123.9749

Interface LngLatLike

A LngLat object, an array of two numbers representing longitude and latitude,
or an object with lng and lat or lon and lat properties.

LngLatBounds

A LngLatBounds object represents a geographical bounding box,
defined by its southwest and northeast points in longitude and latitude.

If no arguments are provided to the constructor, a null bounding box is created.

Note that any Mapbox GL method that accepts a LngLatBounds object as an argument or option
can also accept an Array of two LngLatLike constructs and will perform an implicit conversion.
This flexible type is documented as LngLatBoundsLike .

Constructor

Name
LngLatBounds

new LngLatBounds(sw: any, ne: any)


Parameters


  1. sw: any
  2. ne: any

Methods

Method
contains

contains(lnglat: LngLatLike)


Parameters


  1. lnglat: LngLatLike

Return Value: boolean


Check if the point is within the bounding box.
extend

extend(obj: LngLatLike | LngLatBoundsLike)


Parameters


  1. obj: LngLatLike | LngLatBoundsLike

Return Value: any


Extend the bounds to include a given LngLatLike or LngLatBoundsLike.
getCenter

getCenter()



Return Value: LngLat


Returns the geographical coordinate equidistant from the bounding box's corners.
getEast

getEast()



Return Value: number


Returns the east edge of the bounding box.
getNorth

getNorth()



Return Value: number


Returns the north edge of the bounding box.
getNorthEast

getNorthEast()



Return Value: LngLat


Returns the northeast corner of the bounding box.
getNorthWest

getNorthWest()



Return Value: LngLat


Returns the northwest corner of the bounding box.
getSouth

getSouth()



Return Value: number


Returns the south edge of the bounding box.
getSouthEast

getSouthEast()



Return Value: LngLat


Returns the southeast corner of the bounding box.
getSouthWest

getSouthWest()



Return Value: LngLat


Returns the southwest corner of the bounding box.
getWest

getWest()



Return Value: number


Returns the west edge of the bounding box.
isEmpty

isEmpty()



Return Value: boolean


Check if the bounding box is an empty/ null -type box.
setNorthEast

setNorthEast(ne: LngLatLike)


Parameters


  1. ne: LngLatLike

Return Value: LngLatBounds


Set the northeast corner of the bounding box
setSouthWest

setSouthWest(sw: LngLatLike)


Parameters


  1. sw: LngLatLike

Return Value: LngLatBounds


Set the southwest corner of the bounding box
toArray

toArray()



Return Value: none


Returns the bounding box represented as an array.
toString

toString()



Return Value: string


Return the bounding box represented as a string.
convert

convert(input: LngLatBoundsLike)


Parameters


  1. input: LngLatBoundsLike

Return Value: LngLatBounds


Converts an array to a LngLatBounds object.

If a LngLatBounds object is passed in, the function returns it unchanged.

Internally, the function calls LngLat#convert to convert arrays to LngLat values.

Example

1
var sw = new nextbillion.maps.LngLat(-73.9876, 40.7661);
2
var ne = new nextbillion.maps.LngLat(-73.9397, 40.8002);
3
var llb = new nextbillion.maps.LngLatBounds(sw, ne);

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

Name
MercatorCoordinate

new MercatorCoordinate(x: number, y: number, z: number)


Parameters


  1. x: number
  2. y: number
  3. z: number

Methods

Method
meterInMercatorCoordinateUnits

meterInMercatorCoordinateUnits()



Return Value: number


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.
toAltitude

toAltitude()



Return Value: number


Returns the altitude in meters of the coordinate.
toLngLat

toLngLat()



Return Value: LngLat


Returns the LngLat for the coordinate.
fromLngLat

fromLngLat(lngLatLike: LngLatLike, altitude: number)


Parameters


  1. lngLatLike: LngLatLike
  2. altitude: number

Return Value: MercatorCoordinate


Project a LngLat to a MercatorCoordinate .

Example

1
var nullIsland = new nextbillion.maps.MercatorCoordinate(0.5, 0.5, 0);

© 2024 NextBillion.ai all rights reserved.