forked from dotnet/maui
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
Description
Changing the Location property on a Microsoft.Maui.Controls.Maps.Pin does not change the location of the Pin on the map.
Steps to Reproduce
- Create a map.
- Add a pin at a location.
- Change the location of the pin:
pin. Location = something; - Observe that the pin does not change its location on the map.
Possible Fix
I believe the reason this doesn't work is this line:
public static void MapLocation(IMapPinHandler handler, IMapPin mapPin)
{
if (mapPin.Location != null)
handler.PlatformView.SetPosition(new LatLng(mapPin.Location.Latitude, mapPin.Location.Longitude));
}The handler maintains a MarkerOptions as its PlatformView and loses track of the Marker instance created in the MapHandler. So updating the Pin's Location property updates the MarkerOptions, which has already been used to create the Marker and is therefore no longer useful. The handler should keep track of the created Marker (which is present in a private list on the MapHandler) and update its Position property directly.
Checklist
- Modify
src/Core/maps/src/Handlers/MapPin/MapPinHandler.Android.cs✓ bf77731 Edit - Running GitHub Actions for
src/Core/maps/src/Handlers/MapPin/MapPinHandler.Android.cs✓ Edit - Modify
src/Compatibility/Maps/src/Android/MapRenderer.cs▶ Edit - Running GitHub Actions for
src/Compatibility/Maps/src/Android/MapRenderer.cs▶ Edit
Reactions are currently unavailable