-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fix Changing Location on a Pin does nothing #30201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Hey there @@NirmalKumarYuvaraj! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you include the sample from the issue in the Gallery? https://github.com/dotnet/maui/tree/main/src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries
@jsuarezruiz , i have modified the gallery and introduced a move pin button to update the pin. |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
_randomLocations[_locationRandomSeed.Next(_randomLocations.Length)]; | ||
|
||
void MoveMapTo(Position location) => | ||
pinsMap.MoveToRegion(MapSpan.FromCenterAndRadius(location, Distance.FromKilometers(5))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be nice to create a constant:
const double DefaultMapRadiusKm = 5.0;
// to avoid potential memory leaks (the Marker is owned by the Google Maps view) | ||
WeakReference<Marker>? _markerWeakReference; | ||
|
||
internal Marker? Marker |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a DisconnectHandler
override to properly clean up the weak reference when the handler is disconnected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jsuarezruiz , Added DisconnectHandler. Please let me know if you have any concerns.
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Issue details
Changing the Location property on a Microsoft.Maui.Controls.Maps.Pin does not change the location of the Pin on the map.
Root cause
MapPinHandler.Android.cs
was only updating theMarkerOptions
object when the Location property changedThe actual
Marker
object already added to the map was not being updated, causing the pin to stay in its original locationDescription of change
AddPins
method inMapHandler
to store marker references in theMapPinHandler
for future property updates, ensuring tighter integration between pins and markers.Validated the behaviour in the following platforms
Issues Fixed
Fixes #12916
Output
Before.mov
After.mov