Skip to main content

Map

An interactive map that displays various layers.

Inherits: LayoutControl

Properties

Events

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 of degree to 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

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

The background color of this control.

initial_camera_fitclass-attributeinstance-attribute

initial_camera_fit: Optional[CameraFit] = None

Defines 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.0

The rotation (in degrees) when the map is first loaded.

initial_zoomclass-attributeinstance-attribute

initial_zoom: Number = 13.0

The zoom when the map is first loaded. If initial_camera_fit is defined 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 = False

Whether 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.

max_zoomclass-attributeinstance-attribute

max_zoom: Optional[Number] = None

The maximum (highest) zoom level of every layer. Each layer can specify additional zoom level restrictions.

min_zoomclass-attributeinstance-attribute

min_zoom: Optional[Number] = None

The minimum (smallest) zoom level of every layer. Each layer can specify additional zoom level restrictions.

Events

on_eventclass-attributeinstance-attribute

on_event: Optional[EventHandler[MapEvent]] = None

Fires when any map events occurs.

on_hoverclass-attributeinstance-attribute

on_hover: Optional[EventHandler[MapHoverEvent]] = None

Fires when a hover event occurs.

on_initclass-attributeinstance-attribute

on_init: Optional[ControlEventHandler[Map]] = None

Fires when the map is initialized.

on_long_pressclass-attributeinstance-attribute

on_long_press: Optional[EventHandler[MapTapEvent]] = None

Fires when a long press event occurs.

on_pointer_cancelclass-attributeinstance-attribute

on_pointer_cancel: Optional[EventHandler[MapPointerEvent]] = None

Fires when a pointer cancel event occurs.

on_pointer_downclass-attributeinstance-attribute

on_pointer_down: Optional[EventHandler[MapPointerEvent]] = None

Fires when a pointer down event occurs.

on_pointer_upclass-attributeinstance-attribute

on_pointer_up: Optional[EventHandler[MapPointerEvent]] = None

Fires when a pointer up event occurs.

on_position_changeclass-attributeinstance-attribute

on_position_change: Optional[EventHandler[MapPositionChangeEvent]] = None

Fires when the map position changes, e.g. when the user pans or zooms the map.

on_secondary_tapclass-attributeinstance-attribute

on_secondary_tap: Optional[EventHandler[MapTapEvent]] = None

Fires when a secondary tap event occurs.

on_tapclass-attributeinstance-attribute

on_tap: Optional[EventHandler[MapTapEvent]] = None

Fires when a tap event occurs.

Methods

center_onasync

center_on(point: MapLatitudeLongitude, zoom: Optional[Number], animation_curve: Optional[AnimationCurve] = None, animation_duration: Optional[DurationValue] = None, cancel_ongoing_animations: bool = False)

Centers the map on the given point.

Parameters:

  • point (MapLatitudeLongitude) - The point on which to center the map.
  • zoom (Optional[Number]) - The zoom level to be applied.
  • animation_curve (Optional[AnimationCurve], default: None) - The curve of the animation. If None (the default), flet_map.Map.animation_curve will be used.
  • animation_duration (Optional[DurationValue], default: None) - The duration of the animation. If None (the default), flet_map.Map.animation_duration will 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()

Gets the current camera snapshot of the map.

Returns:

  • Current (Camera) - class:~flet_map.Camera state.

move_toasync

move_to(destination: Optional[MapLatitudeLongitude] = None, zoom: Optional[Number] = None, rotation: Optional[Number] = None, animation_curve: Optional[AnimationCurve] = None, animation_duration: Optional[DurationValue] = None, offset: OffsetValue = (0, 0), cancel_ongoing_animations: bool = False)

Moves to a specific location.

Parameters:

  • destination (Optional[MapLatitudeLongitude], default: None) - The destination point to move to.
  • zoom (Optional[Number], default: None) - The zoom level to be applied. If provided, must be greater than or equal to 0.0.
  • rotation (Optional[Number], default: None) - Rotation (in degrees) to be applied.
  • offset (OffsetValue, default: (0, 0)) - The offset to be used. Only works when rotation is None.
  • animation_curve (Optional[AnimationCurve], default: None) - The curve of the animation. If None (the default), flet_map.Map.animation_curve will be used.
  • animation_duration (Optional[DurationValue], default: None) - The duration of the animation. If None (the default), flet_map.Map.animation_duration will be used.
  • cancel_ongoing_animations (bool, default: False) - Whether to cancel/stop all ongoing map-animations before starting this new one.

Raises:

  • ValueError - If zoom is not None and is negative.

reset_rotationasync

reset_rotation(animation_curve: Optional[AnimationCurve] = None, animation_duration: Optional[DurationValue] = None, cancel_ongoing_animations: bool = False)

Resets the map's rotation to 0 degrees.

Parameters:

  • animation_curve (Optional[AnimationCurve], default: None) - The curve of the animation. If None (the default), flet_map.Map.animation_curve will be used.
  • animation_duration (Optional[DurationValue], default: None) - The duration of the animation. If None (the default), flet_map.Map.animation_duration will 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: Optional[AnimationCurve] = None, animation_duration: Optional[DurationValue] = None, cancel_ongoing_animations: bool = False)

Applies a rotation of degree to the current rotation.

Parameters:

  • degree (Number) - The number of degrees to increment to the current rotation.
  • animation_curve (Optional[AnimationCurve], default: None) - The curve of the animation. If None (the default), flet_map.Map.animation_curve will be used.
  • animation_duration (Optional[DurationValue], default: None) - The duration of the animation. If None (the default), flet_map.Map.animation_duration will 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: Optional[AnimationCurve] = None, animation_duration: Optional[DurationValue] = None, cancel_ongoing_animations: bool = False)

Zooms in by one zoom-level from the current one.

Parameters:

  • animation_curve (Optional[AnimationCurve], default: None) - The curve of the animation. If None (the default), flet_map.Map.animation_curve will be used.
  • animation_duration (Optional[DurationValue], default: None) - The duration of the animation. If None (the default), flet_map.Map.animation_duration will 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: Optional[AnimationCurve] = None, animation_duration: Optional[DurationValue] = None, cancel_ongoing_animations: bool = False)

Zooms out by one zoom-level from the current one.

Parameters:

  • animation_curve (Optional[AnimationCurve], default: None) - The curve of the animation. If None (the default), flet_map.Map.animation_curve will be used.
  • animation_duration (Optional[DurationValue], default: None) - The duration of the animation. If None (the default), flet_map.Map.animation_duration will 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: Optional[AnimationCurve] = None, animation_duration: Optional[DurationValue] = None, cancel_ongoing_animations: bool = False)

Zoom the map to a specific zoom level.

Parameters:

  • zoom (Number) - The zoom level to zoom to.
  • animation_curve (Optional[AnimationCurve], default: None) - The curve of the animation. If None (the default), flet_map.Map.animation_curve will be used.
  • animation_duration (Optional[DurationValue], default: None) - The duration of the animation. If None (the default), flet_map.Map.animation_duration will be used.
  • cancel_ongoing_animations (bool, default: False) - Whether to cancel/stop all ongoing map-animations before starting this new one.