bounding box
A bounding box is a mechanism for describing a particular area of a map. It is typically expressed as an array of coordinate pairs, with the first coordinate pair referring to the southwestern corner of the box (the minimum longitude and latitude) and the second referring to the northeastern corner of the box (the maximum longitude and latitude).
This Mapbox GL JS example creates a bounding box using the LngLatBounds
method:
const southWest = new mapboxgl.LngLat(-73.9876, 40.7661);
const northEast = new mapboxgl.LngLat(-73.9397, 40.8002);
const boundingBox = new mapboxgl.LngLatBounds(southWest, northEast);
Related resources:
Any Mapbox library that creates maps or initiates geocoding requests has a class or object for using bounding boxes in your code:
- Mapbox Geocoding API
bbox
parameter documentation - Mapbox GL JS
LngLatBounds
documentation - Mapbox Maps SDK for iOS
CoordinateBounds
documentation - Mapbox Maps SDK for Android
CoordinateBounds
class documentation - Mapbox Java SDK
MapboxGeocoding.Builder.bbox()
method documentation - Mapbox Search SDK for iOS
BoundingBox
documentation - Turf.js
turf.bbox
documentation - Location helper - interact with a map and get bounding box values to use in your code.
Was this page helpful?