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:
var southWest = new mapboxgl.LngLat(-73.9876, 40.7661);
var northEast = new mapboxgl.LngLat(-73.9397, 40.8002);
var 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.js
L.LatLngBounds
documentation - Mapbox GL JS
LngLatBounds
documentation - Mapbox Maps SDK for iOS
MGLCoordinateBounds
documentation - Mapbox Maps SDK for Android
BoundingBox
class documentation - Mapbox Java SDK
MapboxGeocoding.Builder.bbox()
method documentation - MapboxGeocoder.swift
RectangularRegion
class documentation - Turf.js
turf.bbox
documentation