ViewportController
Last updated
Was this helpful?
Last updated
Was this helpful?
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
<>
Gets the current state of the viewport.
Promise
<>
Moves the map to the specified location.
viewport
void
Gets the current state of the viewport constraints.
Constrains the map viewport so it stays inside certain bounds and/or certain zoom levels.
constraints
void
every constraint is optional
if a constraint is null, it will be removed but keeping the others
if method receives null, it will remove the constraints
Fits the map to the specified bounds.
bounds
void
Adds a listener for when the viewport changes.
args
-
args.handler
This callback is called with the current viewport state whenever the viewport changes.
VoidFunction
A function to unsubscribe from the listener
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.
args
args.handler
VoidFunction
A function to unsubscribe from the listener
onMapIdle(
args
: {handler
: () =>void
; }):VoidFunction
Adds a listener for when the map is idle, which is defined as:
No transitions are in progress
The user is not interacting with the map, e.g. by panning or zooming
All tiles for the current viewport have been loaded
Any fade transitions (e.g. for labels) have completed
args
{ handler
: () => void
; }
args.handler
() => void
VoidFunction
A function to unsubscribe from the listener
setViewport(viewport
: ): void
getViewportConstraints(): Promise
<null
| >
Promise
<null
| >
setViewportConstraints(constraints
: null
| Partial
<>): void
null
| Partial
<>
fitViewportToBounds(bounds
: ): void
onViewportMove(args
: { handler
: (viewport
: ) => void
; }): VoidFunction
{ handler
: (viewport
: ) => void
; }
(viewport
: ) => void
onViewportMoveEnd(args
: { handler
: (viewport
: ) => void
; }): VoidFunction
{ handler
: (viewport
: ) => void
; }
(viewport
: ) => void