JS API
- Parameters
- Options
- Example
- Methods
- fitToBoundingBox
- getBoundingBox
- getInitialBoundingBox
- getLayers
- getMouseMode
- off
- on
- once
- refresh
- reset
- setMouseMode
- usingLayer
- usingNewLayer
- Events
- Parameters
- Example
- Methods
- addFeature
- addFeatureCollection
- bringForwards
- bufferGeometry
- changeProperties
- clearFilters
- clearFeatures
- clearStyle
- clipByFeatureCollection
- convertToCentroids
- filterByBoundingBox
- filterByFeatureCollection
- filterByNearest
- filterByText
- getFeatureCollection
- hide
- sendBackwards
- show
- style
- update
- usingFeature
fitToBoundingBox
Sets the map view to contain a bounding box.
Parameters
Name | Required | Description |
---|---|---|
bbox | Yes | The bounding box that you want to contain in the view. If the bounding box has a different aspect ratio to the map, the map will make sure everything in the bounding box is visible. The format of the bbox parameter is an array of numbers and conforms to the GeoJSON standard for a bounding box i.e. [minX, minY, maxX, maxY] where: - minX (The minimum x-value of the bounding box) - minY (The minimum y-value of the bounding box) - maxX (The maximum x-value of the bounding box) - maxY (The maximum y-value of the bounding box) |
buffer | No | Expands (or contracts) the BoundingBox by this ratio. For example a value of 2 will make the bounding box twice as big and a value of 0.5 will make it half the size. |
Example
var map = new Mapzania.Map("map-div", "WORLD");
map.fitToBoundingBox([12.1,3.4,14.3,4.2], 1.25);