VladislavAntonyuk/MauiSamples

MauiMaps CustomPin iOS Location and Label Set properties ignored after pin added to the map.

mikebikerider opened this issue · 3 comments

CustomPin once created loses base class functionality. When I assign Location to the pin after it was added to the map, it is not reflected on the map. Neither does changing pin Label text.
If pin is created with IsDraggable set to true, it can be dragged across the map. When I check the Location property after dragging to a new position, coordinates are same as passed in the Pin constructor.
Custom pins in your example represent cities. Cities don't move. If the pin represents something moving like a vehicle it would be an issue.
I did not test for Android.

Pin coordinates after drag are not reflected immediately. After another drag or two Location Get{} returns a previous drag location. OnDragEnd() if implemented should fix that.
CustomPin.Location Set{} does not work on iOS. Neither does CoustomPin.Label Set {}.

you can copy handler implementation from .NET MAUI repo. https://github.com/dotnet/maui/tree/main/src/Core/maps/src/Handlers/Map.
Pin is immutable after creation, so if you need to change it, remove the old pin and add a new one.
as for IsDraggable property, it is not mapped, so need to implement the logic to get the new location after dragging to a new position.
I added real time location tracker, that should answer your question.

The MAUI MapPin has associated handler that allows changing Label and Coordinates without recreating the Pin: https://github.com/dotnet/maui/tree/main/src/Core/maps/src/Handlers/MapPin.
A broader question is whether I can come close to doing with MAUI maps what I was doing for 5 years with Xamarin.Forms.GoogleMaps? 994K downloads. The last time I checked Microsoft.Maui.Controls.Maps 33.4K downloads.
I am writing GPS fleet tracking apps. Tens to hundreds of pins (graphics) moving.