The parameters for the fitViewportToBounds
method.
bounds: [
number
,number
,number
,number
]
The bounds to fit the viewport to.
The input type for setting the viewport to a particular center and zoom.
center:
LatLng
The center of the viewport in latitude and longitude.
zoom:
number
The zoom level of the viewport.
The Viewport module allows you to control the viewport of the map, such as setting the current viewport, getting the current viewport, and being notified when the viewport changes.
The current state of the viewport, including the derived bounds.
center:
LatLng
The center of the viewport in latitude and longitude.
zoom:
number
The zoom level of the viewport.
bounds: [
number
,number
,number
,number
]
The bounding box of the viewport.
This is derived, and depends on the center and zoom of the viewport, as well as its size.
The viewport controller allows you to control the viewport of the map.
You can get the current viewport, move the viewport, and be notified when the viewport changes.
getViewport():
Promise
<ViewportState
>
Gets the current state of the viewport.
Returns
Promise
<ViewportState
>
setViewport(
viewport
:SetViewportCenterZoomParams
):void
Moves the map to the specified location.
Parameters
Returns
void
Example
fitViewportToBounds(
bounds
:ViewportFitBoundsParams
):void
Fits the map to the specified bounds.
Parameters
Returns
void
Example
onViewportMove(
args
: {handler
: (viewport
:ViewportState
) =>void
; }):VoidFunction
Adds a listener for when the viewport changes.
Parameters
Returns
VoidFunction
A function to unsubscribe from the listener
Example
onViewportMoveEnd(
args
: {handler
: (viewport
:ViewportState
) =>void
; }):VoidFunction
Adds a listener for when the viewport move ends, which is when the user stops dragging or zooming the map, animations have finished, or inertial dragging ends.
Parameters
Returns
VoidFunction
A function to unsubscribe from the listener
Example
Parameter | Type |
---|---|
Parameter | Type |
---|---|
Parameter | Type | Description |
---|---|---|
Parameter | Type |
---|---|
viewport
bounds
args
object
-
args.handler
(viewport
: ViewportState
) => void
This callback is called with the current viewport state whenever the viewport changes.
args
object
args.handler
(viewport
: ViewportState
) => void
|
| Latitude |
|
| Longitude |