cameraForBounds method
@memberof MapboxMap#
@param {LatLngBoundsLike} bounds Calculate the center for these bounds in the viewport and use
the highest zoom level up to and including MapboxMap#getMaxZoom()
that fits
in the viewport. LatLngBounds represent a box that is always axis-aligned with bearing 0.
@param options
@param {number | PaddingOptions} options.padding
The amount of padding in pixels to add to the given bounds.
@param {PointLike} options.offset=[0, 0]
The center of the given bounds relative to the map's center, measured in pixels.
@param {number} options.maxZoom
The maximum zoom level to allow when the camera would transition to the specified bounds.
@returns {CameraOptions | void} If map is able to fit to provided bounds, returns CameraOptions
with
center
, zoom
, and bearing
. If map is unable to fit, method will warn and return undefined.
@example
var bbox = [-79, 43
, -73, 45
];
var newCameraTransform = map.cameraForBounds(bbox, {
padding: {top: 10, bottom:25, left: 15, right: 5}
});
Implementation
CameraOptions cameraForBounds(LngLatBounds bounds, [dynamic options]) {
if (options == null) {
return CameraOptions.fromJsObject(
jsObject.cameraForBounds(bounds.jsObject));
}
return CameraOptions.fromJsObject(jsObject.cameraForBounds(bounds.jsObject,
options is CameraOptions ? options.jsObject : jsify(options)));
}