-
-
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 the bounds to include a given LngLat or LngLatBounds.
Returns:
`this`
-
-
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}
-
-
Returns the east edge of the bounding box.
Returns:
The east edge of the bounding box.
-
-
Returns the north edge of the bounding box.
Returns:
The north edge of the bounding box.
-
-
Returns the northeast corner of the bounding box.
Returns:
The northeast corner of the bounding box.
-
-
Returns the northwest corner of the bounding box.
Returns:
The northwest corner of the bounding box.
-
-
Returns the south edge of the bounding box.
Returns:
The south edge of the bounding box.
-
-
Returns the southeast corner of the bounding box.
Returns:
The southeast corner of the bounding box.
-
-
Returns the southwest corner of the bounding box.
Returns:
The southwest corner of the bounding box.
-
-
Returns the west edge of the bounding box.
Returns:
The west edge of the bounding box.
-
-
Check if the bounding box is an empty/`null`-type box.
Returns:
True if bounds have been defined, otherwise false.
-
-
Set the northeast corner of the bounding box
Name |
Type |
Description |
ne |
LngLatLike
|
|
Returns:
`this`
-
-
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]]
-
-
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))"