-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
Duplicate Check
- I have searched the opened issues and there are no duplicates
Describe the bug
The position of markers on the map does not change after modifying their coordinates followed by updating the map/layer.
The issue is resolved only by replacing the marker with a new instance containing the new coordinates and updating the layer.
Code sample
Code
import flet as ft
from flet_map import (
Map, InteractionConfiguration, InteractionFlag, MapLatitudeLongitude,
TileLayer, MarkerLayer, Marker
)
OPEN_STREET_MAP_URL = 'https://tile.openstreetmap.org/{z}/{x}/{y}.png'
def main(page: ft.Page):
page.window.width = 400
page.window.height = 600
async def handle_tap(e):
marker = maps.layers[1].markers[0]
marker.coordinates = e.coordinates
maps.layers[1].update()
async def alternative_handler(e):
marker = Marker(
content=ft.Icon(ft.Icons.random(), color=ft.Colors.BLACK),
coordinates=e.coordinates
)
maps.layers[1].markers[0] = marker
maps.layers[1].update()
maps = Map(
expand=True,
initial_center=MapLatitudeLongitude(50.599, 36.598),
initial_zoom=10,
interaction_configuration=InteractionConfiguration(
flags=InteractionFlag.ALL
),
keep_alive=True,
max_zoom=20,
min_zoom=2,
layers=[
TileLayer(url_template=OPEN_STREET_MAP_URL),
MarkerLayer([
Marker(
content=ft.Icon(ft.Icons.random(), color=ft.Colors.BLACK),
coordinates=MapLatitudeLongitude(50.599, 36.598)
)
])
],
on_tap=handle_tap,
on_long_press=alternative_handler
)
page.add(maps)
if __name__ == '__main__':
ft.run(main)To reproduce
Run the code
Expected behavior
I expect the marker's position to change after its coordinates are changed and the layer/map is updated.
Screenshots / Videos
No response
Operating System
macOS
Operating system details
26.2
Flet version
0.80.1
Regression
I'm not sure / I don't know
Suggestions
No response
Logs
No response
Additional details
No response