Map
An interactive map that displays various layers.
Inherits: LayoutControl
Properties
animation_curve- The default animation curve to be used for map-animations when calling instance methods likezoom_in,rotate_from,move_toetc.animation_duration- The default animation duration to be used for map-animations when calling instance methods likezoom_in,rotate_from,move_toetc.bgcolor- The background color of this control.initial_camera_fit- Defines the visible bounds when the map is first loaded.initial_center- The initial center of the map.initial_rotation- The rotation (in degrees) when the map is first loaded.initial_zoom- The zoom when the map is first loaded.interaction_configuration- The interaction configuration.keep_alive- Whether to enable the built in keep-alive functionality.layers- A list of layers to be displayed (stack-like) on the map.max_zoom- The maximum (highest) zoom level of every layer.min_zoom- The minimum (smallest) zoom level of every layer.
Events
on_event- Fires when any map events occurs.on_hover- Fires when a hover event occurs.on_init- Fires when the map is initialized.on_long_press- Fires when a long press event occurs.on_pointer_cancel- Fires when a pointer cancel event occurs.on_pointer_down- Fires when a pointer down event occurs.on_pointer_up- Fires when a pointer up event occurs.on_position_change- Fires when the map position changes, e.g.on_secondary_tap- Fires when a secondary tap event occurs.on_tap- Fires when a tap event occurs.
Methods
center_on- Centers the map on the given point.get_camera- Gets the current camera snapshot of the map.move_to- Moves to a specific location.reset_rotation- Resets the map's rotation to 0 degrees.rotate_from- Applies a rotation ofdegreeto the current rotation.zoom_in- Zooms in by one zoom-level from the current one.zoom_out- Zooms out by one zoom-level from the current one.zoom_to- Zoom the map to a specific zoom level.
Properties
animation_curveclass-attributeinstance-attribute
animation_curve: AnimationCurve = (
AnimationCurve.FAST_OUT_SLOWIN
)The default animation curve to be used for map-animations
when calling instance methods like zoom_in,
rotate_from,
move_to etc.
animation_durationclass-attributeinstance-attribute
animation_duration: DurationValue = field(
default_factory=lambda: Duration(milliseconds=500)
)The default animation duration to be used for map-animations
when calling instance methods like zoom_in,
rotate_from,
move_to etc.
bgcolorclass-attributeinstance-attribute
bgcolor: ColorValue = Colors.GREY_300The background color of this control.
initial_camera_fitclass-attributeinstance-attribute
initial_camera_fit: CameraFit | None = NoneDefines the visible bounds when the map is first loaded.
Takes precedence over initial_center/initial_zoom.
initial_centerclass-attributeinstance-attribute
initial_center: MapLatitudeLongitude = field(
default_factory=lambda: MapLatitudeLongitude(
latitude=50.5, longitude=30.51
)
)The initial center of the map.
initial_rotationclass-attributeinstance-attribute
initial_rotation: Number = 0.0The rotation (in degrees) when the map is first loaded.
initial_zoomclass-attributeinstance-attribute
initial_zoom: Number = 13.0The zoom when the map is first loaded.
If initial_camera_fit is non-None this has no effect.
interaction_configurationclass-attributeinstance-attribute
interaction_configuration: InteractionConfiguration = field(
default_factory=lambda: InteractionConfiguration()
)The interaction configuration.
keep_aliveclass-attributeinstance-attribute
keep_alive: bool = FalseWhether to enable the built in keep-alive functionality.
If the map is within a complex layout, such as a ListView,
the map will reset to its initial position after it appears back into view.
To ensure this doesn't happen, enable this flag to prevent it from rebuilding.
layersinstance-attribute
layers: list[MapLayer]A list of layers to be displayed (stack-like) on the map.
Events
on_eventclass-attributeinstance-attribute
on_event: EventHandler[MapEvent] | None = NoneFires when any map events occurs.
on_hoverclass-attributeinstance-attribute
on_hover: EventHandler[MapHoverEvent] | None = NoneFires when a hover event occurs.
on_initclass-attributeinstance-attribute
on_init: ControlEventHandler[Map] | None = NoneFires when the map is initialized.
on_long_pressclass-attributeinstance-attribute
on_long_press: EventHandler[MapTapEvent] | None = NoneFires when a long press event occurs.
on_pointer_cancelclass-attributeinstance-attribute
on_pointer_cancel: (
EventHandler[MapPointerEvent] | None
) = NoneFires when a pointer cancel event occurs.
on_pointer_downclass-attributeinstance-attribute
on_pointer_down: EventHandler[MapPointerEvent] | None = (
None
)Fires when a pointer down event occurs.
on_pointer_upclass-attributeinstance-attribute
on_pointer_up: EventHandler[MapPointerEvent] | None = (
None
)Fires when a pointer up event occurs.
on_position_changeclass-attributeinstance-attribute
on_position_change: (
EventHandler[MapPositionChangeEvent] | None
) = NoneFires when the map position changes, e.g. when the user pans or zooms the map.
on_secondary_tapclass-attributeinstance-attribute
on_secondary_tap: EventHandler[MapTapEvent] | None = NoneFires when a secondary tap event occurs.
on_tapclass-attributeinstance-attribute
on_tap: EventHandler[MapTapEvent] | None = NoneFires when a tap event occurs.
Methods
center_onasync
center_on(
point: MapLatitudeLongitude,
zoom: Number | None,
animation_curve: AnimationCurve | None = None,
animation_duration: DurationValue | None = None,
cancel_ongoing_animations: bool = False,
) -> NoneCenters the map on the given point.
Parameters:
- point (MapLatitudeLongitude) - The point on which to center the map.
- zoom (Number | None) - The zoom level to be applied.
- animation_curve (AnimationCurve | None, default:
None) - The curve of the animation. IfNone(the default),Map.animation_curvewill be used. - animation_duration (DurationValue | None, default:
None) - The duration of the animation. If None (the default),Map.animation_durationwill be used. - cancel_ongoing_animations (bool, default:
False) - Whether to cancel/stop all ongoing map-animations before starting this new one.
get_cameraasync
get_camera() -> CameraGets the current camera snapshot of the map.
Returns:
- Camera - The current camera state.
move_toasync
move_to(
destination: MapLatitudeLongitude | None = None,
zoom: Number | None = None,
rotation: Number | None = None,
animation_curve: AnimationCurve | None = None,
animation_duration: DurationValue | None = None,
offset: OffsetValue = (0, 0),
cancel_ongoing_animations: bool = False,
) -> NoneMoves to a specific location.
Parameters:
- destination (MapLatitudeLongitude | None, default:
None) - The destination point to move to. - zoom (Number | None, default:
None) - The zoom level to be applied. If provided, must be greater than or equal to0.0. - rotation (Number | None, default:
None) - Rotation (in degrees) to be applied. - offset (OffsetValue, default:
(0, 0)) - The offset to be used. Only works whenrotationisNone. - animation_curve (AnimationCurve | None, default:
None) - The curve of the animation. If None (the default),Map.animation_curvewill be used. - animation_duration (DurationValue | None, default:
None) - The duration of the animation. If None (the default),Map.animation_durationwill be used. - cancel_ongoing_animations (bool, default:
False) - Whether to cancel/stop all ongoing map-animations before starting this new one.
Raises:
- ValueError - If
zoomis notNoneand is negative.
reset_rotationasync
reset_rotation(
animation_curve: AnimationCurve | None = None,
animation_duration: DurationValue | None = None,
cancel_ongoing_animations: bool = False,
) -> NoneResets the map's rotation to 0 degrees.
Parameters:
- animation_curve (AnimationCurve | None, default:
None) - The curve of the animation. If None (the default),Map.animation_curvewill be used. - animation_duration (DurationValue | None, default:
None) - The duration of the animation. If None (the default),Map.animation_durationwill be used. - cancel_ongoing_animations (bool, default:
False) - Whether to cancel/stop all ongoing map-animations before starting this new one.
rotate_fromasync
rotate_from(
degree: Number,
animation_curve: AnimationCurve | None = None,
animation_duration: DurationValue | None = None,
cancel_ongoing_animations: bool = False,
) -> NoneApplies a rotation of degree to the current rotation.
Parameters:
- degree (Number) - The number of degrees to increment to the current rotation.
- animation_curve (AnimationCurve | None, default:
None) - The curve of the animation. If None (the default),Map.animation_curvewill be used. - animation_duration (DurationValue | None, default:
None) - The duration of the animation. If None (the default),Map.animation_durationwill be used. - cancel_ongoing_animations (bool, default:
False) - Whether to cancel/stop all ongoing map-animations before starting this new one.
zoom_inasync
zoom_in(
animation_curve: AnimationCurve | None = None,
animation_duration: DurationValue | None = None,
cancel_ongoing_animations: bool = False,
) -> NoneZooms in by one zoom-level from the current one.
Parameters:
- animation_curve (AnimationCurve | None, default:
None) - The curve of the animation. If None (the default),Map.animation_curvewill be used. - animation_duration (DurationValue | None, default:
None) - The duration of the animation. If None (the default),Map.animation_durationwill be used. - cancel_ongoing_animations (bool, default:
False) - Whether to cancel/stop all ongoing map-animations before starting this new one.
zoom_outasync
zoom_out(
animation_curve: AnimationCurve | None = None,
animation_duration: DurationValue | None = None,
cancel_ongoing_animations: bool = False,
) -> NoneZooms out by one zoom-level from the current one.
Parameters:
- animation_curve (AnimationCurve | None, default:
None) - The curve of the animation. IfNone(the default),Map.animation_curvewill be used. - animation_duration (DurationValue | None, default:
None) - The duration of the animation. If None (the default),Map.animation_durationwill be used. - cancel_ongoing_animations (bool, default:
False) - Whether to cancel/stop all ongoing map-animations before starting this new one.
zoom_toasync
zoom_to(
zoom: Number,
animation_curve: AnimationCurve | None = None,
animation_duration: DurationValue | None = None,
cancel_ongoing_animations: bool = False,
) -> NoneZoom the map to a specific zoom level.
Parameters:
- zoom (Number) - The zoom level to zoom to.
- animation_curve (AnimationCurve | None, default:
None) - The curve of the animation. IfNone(the default),Map.animation_curvewill be used. - animation_duration (DurationValue | None, default:
None) - The duration of the animation. If None (the default),Map.animation_durationwill be used. - cancel_ongoing_animations (bool, default:
False) - Whether to cancel/stop all ongoing map-animations before starting this new one.