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.

new SuperMap3D.LngLatBounds(sw, ne)

Name Type Description
sw LngLatLike optional The southwest corner of the bounding box.
ne LngLatLike optional The northeast corner of the bounding box.
Example:
var sw = new mapboxgl.LngLat(-73.9876, 40.7661);
var ne = new mapboxgl.LngLat(-73.9397, 40.8002);
var llb = new mapboxgl.LngLatBounds(sw, ne);

Methods

staticSuperMap3D.LngLatBounds.convert(input)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.
Name Type Description
input LngLatBoundsLike An array of two coordinates to convert, or a `LngLatBounds` object to return.
Returns:
A new `LngLatBounds` object, if a conversion occurred, or the original `LngLatBounds` object.
Example:
var arr = [[-73.9876, 40.7661], [-73.9397, 40.8002]];
var llb = mapboxgl.LngLatBounds.convert(arr);
llb;   // = LngLatBounds {_sw: LngLat {lng: -73.9876, lat: 40.7661}, _ne: LngLat {lng: -73.9397, lat: 40.8002}}

contains(lnglat)boolean

Check if the point is within the bounding box.
Name Type Description
lnglat LngLatLike geographic point to check against.
Returns:
True if the point is within the bounding box.

extend(obj)LngLatBounds

Extend the bounds to include a given LngLat or LngLatBounds.
Name Type Description
obj LngLat | LngLatBounds object to extend to
Returns:
`this`

getCenter()LngLat

Returns the geographical coordinate equidistant from the bounding box's corners.
Returns:
The bounding box's center.
Example:
var llb = new mapboxgl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
llb.getCenter(); // = LngLat {lng: -73.96365, lat: 40.78315}

getEast()number

Returns the east edge of the bounding box.
Returns:
The east edge of the bounding box.

getNorth()number

Returns the north edge of the bounding box.
Returns:
The north edge of the bounding box.

getNorthEast()LngLat

Returns the northeast corner of the bounding box.
Returns:
The northeast corner of the bounding box.

getNorthWest()LngLat

Returns the northwest corner of the bounding box.
Returns:
The northwest corner of the bounding box.

getSouth()number

Returns the south edge of the bounding box.
Returns:
The south edge of the bounding box.

getSouthEast()LngLat

Returns the southeast corner of the bounding box.
Returns:
The southeast corner of the bounding box.

getSouthWest()LngLat

Returns the southwest corner of the bounding box.
Returns:
The southwest corner of the bounding box.

getWest()number

Returns the west edge of the bounding box.
Returns:
The west edge of the bounding box.

isEmpty()boolean

Check if the bounding box is an empty/`null`-type box.
Returns:
True if bounds have been defined, otherwise false.

setNorthEast(ne)LngLatBounds

Set the northeast corner of the bounding box
Name Type Description
ne LngLatLike
Returns:
`this`

setSouthWest(sw)LngLatBounds

Set the southwest corner of the bounding box
Name Type Description
sw LngLatLike
Returns:
`this`

toArray()Array.<Array.<number>>

Returns the bounding box represented as an array.
Returns:
The bounding box represented as an array, consisting of the southwest and northeast coordinates of the bounding represented as arrays of numbers.
Example:
var llb = new mapboxgl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
llb.toArray(); // = [[-73.9876, 40.7661], [-73.9397, 40.8002]]

toString()string

Return the bounding box represented as a string.
Returns:
The bounding box represents as a string of the format `'LngLatBounds(LngLat(lng, lat), LngLat(lng, lat))'`.
Example:
var llb = new mapboxgl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
llb.toString(); // = "LngLatBounds(LngLat(-73.9876, 40.7661), LngLat(-73.9397, 40.8002))"