FollowPuckViewportState class final
A ViewportState that configures the camera to follow the user's location indicator (puck).
The FollowPuckViewportState adjusts the camera to continuously track the user's current location on the map. This is ideal for applications that require real-time user positioning, such as navigation or fitness apps.
You can customize the camera's behavior using the zoom, bearing, and pitch parameters:
- The zoom level determines how close the camera is to the map's surface. Higher values result in a closer view.
- The bearing controls the rotation of the map and can be set to follow the user's heading or a custom value using FollowPuckViewportStateBearing.
- The pitch adjusts the angle of the camera toward the horizon, providing a 3D perspective when set above zero.
Note: Location should be enabled to use this viewport state.
Note: It is recommended to use only the DefaultViewportTransition animation option when transitioning to the FollowPuckViewportState, as it smoothly handles the moving user location puck. Other animation options like EasingViewportTransition and FlyViewportTransition are not supported and may result in undesired behavior.
Example
final viewportState = FollowPuckViewportState(
zoom: 16.0,
bearing: FollowPuckViewportStateBearingHeading(),
pitch: 45.0,
);
- Inheritance
-
- Object
- ViewportState
- FollowPuckViewportState
Constructors
- FollowPuckViewportState.new({double? zoom = 16.35, FollowPuckViewportStateBearing? bearing = const FollowPuckViewportStateBearingHeading(), double? pitch = 45})
-
Creates a FollowPuckViewportState that configures the camera to follow the user's location indicator.
const
Properties
- bearing → FollowPuckViewportStateBearing?
-
The bearing behavior of the map.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- pitch → double?
-
The pitch of the camera toward the horizon, in degrees.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- zoom → double?
-
The zoom level of the map.
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited