Skip to content

Fix Changing Location on a Pin does nothing#30201

Merged
kubaflo merged 10 commits intodotnet:inflight/currentfrom
NirmalKumarYuvaraj:fix-12916
Apr 12, 2026
Merged

Fix Changing Location on a Pin does nothing#30201
kubaflo merged 10 commits intodotnet:inflight/currentfrom
NirmalKumarYuvaraj:fix-12916

Conversation

@NirmalKumarYuvaraj
Copy link
Copy Markdown
Contributor

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 the MarkerOptions object when the Location property changed
The actual Marker object already added to the map was not being updated, causing the pin to stay in its original location

Description of change

  • Improved marker association logic: Updated the AddPins method in MapHandler to store marker references in the MapPinHandler for future property updates, ensuring tighter integration between pins and markers.

Validated the behaviour in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Issues Fixed

Fixes #12916

Output

Before After
Before.mov
After.mov

@dotnet-policy-service dotnet-policy-service Bot added community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration labels Jun 25, 2025
@jsuarezruiz jsuarezruiz added the area-controls-map Map / Maps label Jun 26, 2025
Copy link
Copy Markdown
Contributor

@jsuarezruiz jsuarezruiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NirmalKumarYuvaraj NirmalKumarYuvaraj marked this pull request as ready for review June 27, 2025 12:57
@NirmalKumarYuvaraj NirmalKumarYuvaraj requested a review from a team as a code owner June 27, 2025 12:57
@NirmalKumarYuvaraj
Copy link
Copy Markdown
Contributor Author

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.

@jsuarezruiz
Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines
Copy link
Copy Markdown

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)));
Copy link
Copy Markdown
Contributor

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;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jsuarezruiz . Done . Please let me know if you have concerns.

// to avoid potential memory leaks (the Marker is owned by the Google Maps view)
WeakReference<Marker>? _markerWeakReference;

internal Marker? Marker
Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

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.

Copilot AI review requested due to automatic review settings July 30, 2025 06:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug where changing the Location property on a Microsoft.Maui.Controls.Maps.Pin does not update the pin's position on the map in Android. The issue was that only the MarkerOptions object was being updated when properties changed, but the actual Marker already added to the map was not being updated.

Key Changes

  • Added marker reference tracking in MapPinHandler to maintain connection between pins and their associated markers
  • Updated property mappers to modify both MarkerOptions and the actual Marker when pin properties change
  • Enhanced the MapPinsGallery sample with functionality to test pin movement

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
MapPinHandler.Android.cs Added WeakReference-based marker tracking and updated property mappers to modify both MarkerOptions and actual Marker
MapHandler.Android.cs Modified AddPins method to store marker reference in MapPinHandler for future property updates
PublicAPI.Unshipped.txt Added new public API entry for the DisconnectHandler override
MapPinsGallery.xaml Added "Move Pin" button to test pin location changes
MapPinsGallery.xaml.cs Implemented pin movement functionality and improved random location handling

Comment thread src/Core/maps/src/Handlers/MapPin/MapPinHandler.Android.cs Outdated
Comment thread src/Core/maps/src/Handlers/Map/MapHandler.Android.cs Outdated
@MauiBot
Copy link
Copy Markdown
Collaborator

MauiBot commented Mar 21, 2026

⚠️ Merge Conflict Detected — This PR has merge conflicts with its target branch. Please rebase onto the target branch and resolve the conflicts.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 21, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://github.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 30201

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://github.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 30201"

@MauiBot MauiBot added s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-gate-failed AI could not verify tests catch the bug s/agent-fix-win AI found a better alternative fix than the PR s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review) labels Mar 21, 2026
@NirmalKumarYuvaraj
Copy link
Copy Markdown
Contributor Author

@kubaflo , Addressed AI summary concerns

@kubaflo kubaflo added the s/agent-fix-implemented PR author implemented the agent suggested fix label Mar 23, 2026
@MauiBot MauiBot added s/agent-review-incomplete AI agent could not complete all phases (blocker, timeout, error) s/agent-changes-requested AI agent recommends changes - found a better alternative or issues and removed s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-review-incomplete AI agent could not complete all phases (blocker, timeout, error) labels Mar 24, 2026
@NirmalKumarYuvaraj
Copy link
Copy Markdown
Contributor Author

@kubaflo , Fix is applied in Map control . For Android platform, we need an API key to render map. so skipped writing test for this PR. I have enabled a button to move the pin in the control gallery sample. You can verify there. Please let me know if you have any concerns.

@MauiBot MauiBot added s/agent-fix-pr-picked AI could not beat the PR fix - PR is the best among all candidates and removed s/agent-fix-win AI found a better alternative fix than the PR labels Mar 30, 2026
@dotnet dotnet deleted a comment from MauiBot Mar 30, 2026
@dotnet dotnet deleted a comment from MauiBot Mar 30, 2026
@dotnet dotnet deleted a comment from MauiBot Mar 30, 2026
@dotnet dotnet deleted a comment from MauiBot Mar 30, 2026
@MauiBot
Copy link
Copy Markdown
Collaborator

MauiBot commented Mar 30, 2026

🚦 Gate — Test Before and After Fix

👋 @NirmalKumarYuvaraj — new gate results are available. Please review the latest session below.

🚦 Gate Session2dd44b2 · updated AI summary · 2026-04-12 15:14 UTC

Gate Result: ⚠️ SKIPPED

No tests were detected in this PR.

Recommendation: Add tests to verify the fix using the write-tests-agent:

@copilot write tests for this PR

The agent will analyze the issue, determine the appropriate test type (UI test, device test, unit test, or XAML test), and create tests that verify the fix.


@MauiBot
Copy link
Copy Markdown
Collaborator

MauiBot commented Mar 30, 2026

🤖 AI Summary

👋 @NirmalKumarYuvaraj — new AI review results are available. Please review the latest session below.

📊 Review Session2dd44b2 · updated AI summary · 2026-04-12 15:50 UTC
🔍 Pre-Flight — Context & Validation

Issue: #12916 - [Maps] [Regression from Xamarin.Forms.Maps] Changing Location on a Pin does nothing
PR: #30201 - Fix Changing Location on a Pin does nothing
Platforms Affected: Android (bug and fix are Android-specific; other platforms not validated by author and not affected since the platform handler code is .Android.cs only)
Files Changed: 2 implementation (MapHandler.Android.cs, MapPinHandler.Android.cs), 1 API (PublicAPI.Unshipped.txt - cosmetic), 2 sample/gallery

Key Findings

  • Root cause: MapPinHandler.MapLocation calls SetPosition on the MarkerOptions template object. Once Map.AddMarker(markerOptions) has been called and the live Marker is created, subsequent changes to MarkerOptions have no effect on the rendered pin. The live Marker must be updated directly.
  • PR's fix: Subscribe INotifyPropertyChanged.PropertyChanged in MapHandler.AddPins(), store live Marker references in _markers list, look up marker by string MarkerId in PinOnPropertyChanged, and update marker.Position/Title/Snippet directly.
  • DisconnectPins(): Called from DisconnectHandler (teardown) and MapPins mapper (full pins refresh). Unsubscribes PropertyChanged AND calls pin?.Handler?.DisconnectHandler() on each pin handler — unusual explicit child-handler lifecycle management.
  • No automated tests: Author notes Google Maps API key is required for Android testing. A gallery "Move Pin" button was added as manual validation.
  • Merge conflict: PR flagged as conflicting with main on 2026-03-21; still unresolved.
  • Prior agent review: Full review completed at commit 2dd44b2 with REQUEST CHANGES verdict (merge conflict + DisconnectPins lifecycle concern). Author addressed concerns (comment 4159960954) but no new commits pushed.
  • Inline review comments (all outdated):
    • jsuarezruiz: Add DefaultMapRadiusKm constant → addressed by author
    • jsuarezruiz: Add DisconnectHandler override to MapPinHandler.Android.cs → author says done (but current file has no override; cleanup was moved to parent MapHandler.DisconnectPins())
    • copilot-pr-reviewer: Null check style consistency (resolved)
    • copilot-pr-reviewer: Breaking IMapPinHandler abstraction concern (resolved)

Fix Candidates

# Source Approach Test Result Files Changed Notes
PR PR #30201 Subscribe INotifyPropertyChanged.PropertyChanged in MapHandler.AddPins(); look up live Marker via O(n) _markers list scan by string MarkerId; update marker.Position/Title/Snippet directly ⚠️ Gate SKIPPED (no tests) MapHandler.Android.cs, MapPinHandler.Android.cs (style-only), PublicAPI.Unshipped.txt (cosmetic), 2 sample files Updated fix; MarkerId stays as string; GetPinForMarker() unchanged

🔧 Fix — Analysis & Comparison

Fix Candidates

# Source Approach Test Result Files Changed Notes
1 try-fix (claude-opus-4.6) Dictionary<IMapPin, Marker> keyed by pin object reference; same PropertyChanged subscription; O(1) lookup ⚠️ BLOCKED (build OK, no device) 1 file Eliminates string MarkerId indirection; clean O(1) lookup
2 try-fix (claude-sonnet-4.6) Action<string>? LiveMarkerUpdate closure on MapPinHandler; MapHandler captures live Marker in closure after AddMarker(); no INPC subscription ⚠️ BLOCKED (build OK, no device) 2 files Zero subscription overhead; update logic stays in MapHandler; most decoupled approach
3 try-fix (gpt-5.3-codex) MapPinMarkerId wrapper object stored in IMapPin.MarkerId; mapper directly updates live Marker via cast ❌ FAIL (build env TFM issue — --no-restore caused MSB3644; code logic sound) 2 files Requires correct build command (-f net10.0-android36.0, no --no-restore)
4 try-fix (gpt-5.4) Remove-and-re-add Marker: MapHandler.RefreshPinMarker() removes old marker and adds fresh one from MarkerOptions; called from MapPinHandler ✅ BUILD PASS (build verified; no device runtime test) 2 files Visual flash on update; correct fix but worse UX; avoids all INPC subscriptions
PR PR #30201 INotifyPropertyChanged.PropertyChanged in MapHandler.AddPins(); O(n) scan of _markers list by string MarkerId; updates marker.Position/Title/Snippet ⚠️ Gate SKIPPED (no tests; author-validated manually) MapHandler.Android.cs, MapPinHandler.Android.cs (style), PublicAPI.Unshipped.txt (cosmetic), 2 sample files Standard MAUI INPC pattern; in-place update (no visual flash); handles Location/Label/Address

Cross-Pollination

Model Round New Ideas? Details
claude-opus-4.6 2 Yes Marker.Tag-based identity: store IMapPin as marker.Tag; iterate markers matching Tag for update — functionally same axis as Dict approaches (still O(n) scan or requires dict); not run as separate attempt
gpt-5.3-codex 2 Yes (but regressive) Store live Marker object in IMapPin.MarkerId — this is the old PR approach known to break GetPinForMarker() string comparison; rejected

Exhausted: Yes — all architectural axes covered: INPC subscription (PR, Attempt 1), closure capture (Attempt 2), wrapper/casting (Attempt 3), remove-and-recreate (Attempt 4). Cross-poll Attempt 2 variants (Tag, Marker-in-MarkerId) are regressions to previously-tried or inferior approaches.

Selected Fix: PR's fix — Uses standard MAUI INPC pattern; in-place marker.Position update (no visual flash); correctly handles Location, Label, and Address changes; MarkerId stays as string so GetPinForMarker() is untouched; most pattern-consistent with rest of MapHandler codebase.


📋 Report — Final Recommendation

⚠️ Final Recommendation: REQUEST CHANGES

Phase Status

Phase Status Notes
Pre-Flight ✅ COMPLETE Issue #12916, Android-only, PR significantly updated; prior full review imported
Gate ⚠️ SKIPPED No automated tests detected in PR
Try-Fix ✅ COMPLETE 4 attempts; 1 build-verified alternative (remove-and-re-add); 2 blocked (no device); 1 env failure; PR's fix selected
Report ✅ COMPLETE

Summary

PR #30201 correctly fixes the long-standing Android regression (#12916) where Pin.Location changes had no visual effect. The root cause is properly identified and the implementation is sound. However, there are two remaining blocking concerns before merge:

  1. DisconnectPins() calls pin?.Handler?.DisconnectHandler() on pin handlers — This manually manages child handler lifecycle from the parent MapHandler. It is called from both DisconnectHandler (teardown) and the MapPins mapper (full pins refresh). The MapPins mapper also calls it during a pins collection refresh, meaning all pin handlers are disconnected and their handlers disconnected on every full refresh. This unusual pattern could cause issues if pin handlers are expected to be managed exclusively by the MAUI framework. A maintainer should explicitly confirm this is the intended lifecycle.

  2. Merge conflict — The PR has an unresolved conflict with main (detected 2026-03-21, still unresolved). Must be resolved before merge.

  3. No automated tests — Author explains Google Maps API key is required. A gallery "Move Pin" button was added as manual validation. The gate was skipped as a result.

  4. PublicAPI.Unshipped.txt trailing newline removal — Cosmetic-only; no functional impact but adds noise to the diff. The file should have a trailing newline per file conventions.

Root Cause

MapPinHandler.MapLocation calls handler.PlatformView.SetPosition(...) on the MarkerOptions template object. Once Map.AddMarker(markerOptions) returns a live Marker, any subsequent changes to the MarkerOptions instance have no effect on the rendered pin. The live Marker must be updated directly. The fix correctly adds a PropertyChanged listener in MapHandler.AddPins() to intercept pin property changes and update the corresponding live Marker.

Fix Quality

The PR's INotifyPropertyChanged.PropertyChanged approach is the best-fit solution for this codebase:

  • Try-Fix confirmed 7+ alternative approaches; none improves on the PR while staying consistent with MAUI patterns.
  • The closest alternative (Attempt 2: closure-based LiveMarkerUpdate) avoids event subscriptions but adds a stateful delegate to MapPinHandler that couples it to MapHandler — rejected by earlier inline review comments.
  • The next best (Attempt 4: remove-and-re-add) builds correctly but causes visual flash on location update — inferior UX.
  • MarkerId correctly remains a string; GetPinForMarker() is unchanged and correct.

Selected Fix: PR — most pattern-consistent, in-place update, handles Location/Label/Address.

Required Before Merge

  1. Resolve merge conflict with main
  2. Review or justify pin?.Handler?.DisconnectHandler() call in DisconnectPins() — confirm this is intended lifecycle management and not an unintended double-disconnect
  3. (Optional) Restore trailing newline in PublicAPI.Unshipped.txt
  4. (Optional) Add a comment in DisconnectPins() explaining why child handler disconnect is explicit here

@NirmalKumarYuvaraj
Copy link
Copy Markdown
Contributor Author

@kubaflo , Addressed AI summary concern. please let me know if you have any concerns.

@kubaflo
Copy link
Copy Markdown
Contributor

kubaflo commented Apr 12, 2026

Code Review — PR #30201

Independent Assessment

What this changes: On Android, subscribes to INotifyPropertyChanged.PropertyChanged on each map pin during AddPins(). When a pin's Location, Label, or Address changes, the corresponding Marker on the Google Map is updated in place. Adds DisconnectPins() to unsubscribe from all pins during DisconnectHandler and before re-adding pins in MapPins mapper. Also adds a "Move Pin" button to the Maps gallery sample.

Inferred motivation: Changing Pin.Location at runtime does nothing on Android because MapPinHandler only sets properties on MarkerOptions (used during marker creation), not on the live Marker object. The fix listens to property changes on the cross-platform pin and propagates them to the native marker.

Reconciliation with PR Narrative

Author claims: Changing Location on a Pin does nothing on Android. Root cause is that only MarkerOptions was being updated, not the live Marker.

Agreement: My analysis matches exactly. The MapPinHandler.MapLocation updates MarkerOptions.SetPosition() which only matters at marker creation time. Once Map.AddMarker() returns a Marker, the MarkerOptions is no longer relevant.

Findings

⚠️ Warning — Pin removal from collection doesn't unsubscribe PropertyChanged

When a single pin is removed from Map.Pins (e.g., pinsMap.Pins.RemoveAt(0)), the MapPins mapper fires and calls DisconnectPins() then AddPins() with the new collection. This works correctly because DisconnectPins() iterates VirtualView.Pins — but by the time the mapper runs, the removed pin is no longer in VirtualView.Pins.

This means a pin that was subscribed in AddPins() but then removed from the collection will never have its PropertyChanged unsubscribed via DisconnectPins(). The handler holds a strong reference to the removed pin via the delegate, preventing GC of both the pin and the handler.

Mitigation: MapPins mapper does call DisconnectPins() before AddPins(), but DisconnectPins() iterates the current VirtualView.Pins — which no longer contains the removed pin. The old subscription leaks.

Suggested fix: Either:

  1. Track subscribed pins in a separate list (like _markers tracks markers), or
  2. In MapPins, iterate the old markers/pins and unsubscribe before clearing, not the current VirtualView.Pins

⚠️ Warning — Android-only fix; iOS and Windows have the same bug

The issue (#12916) reports Android as affected. The fix only modifies MapHandler.Android.cs. However, MapHandler.iOS.cs and MapHandler.Windows.cs (which throws NotImplementedException for MapPins) have no property-change subscription either. If pin location changes are expected to work on iOS/Mac, the same pattern would be needed there. Worth noting — this PR scope is fine for fixing Android, but a follow-up for iOS should be tracked.

⚠️ Warning — No automated test

jsuarezruiz requested a sample in the gallery (addressed), but there's no automated UI test or device test verifying that moving a pin actually changes the marker position. Map tests are notoriously hard to automate, but a device test that adds a pin, changes its location, and verifies the marker's Position via the Google Maps API would catch regressions.

✅ Correct — ConnectHandler/DisconnectHandler symmetry

AddPins subscribes to PropertyChanged; DisconnectPins unsubscribes and disconnects pin handlers. DisconnectPins is called in both DisconnectHandler (cleanup) and MapPins mapper (before re-adding). This follows review rule §1 (handler lifecycle symmetry).

✅ Correct — DisconnectPins placement in DisconnectHandler

DisconnectPins() is called before base.DisconnectHandler() — correct ordering per review rule §1 ("DisconnectHandler should clean up before calling base.DisconnectHandler()").

✅ Correct — Marker lookup by MarkerId is efficient and safe

PinOnPropertyChanged looks up the marker by iterating _markers and matching pin.MarkerId (string). This is O(n) but map pins are typically small collections. The null checks for _markers and marker are proper guards.

✅ Correct — Handles Location, Label, and Address changes

The switch on PropertyName covers all three user-visible marker properties. Location maps to marker.Position, Label to marker.Title, Address to marker.Snippet. This is complete for the current IMapPin interface.

✅ Correct — Gallery sample is well-structured

"Move Pin" button changes pinsMap.Pins[0].Location to a random location and moves the map camera to follow. The MoveMapTo helper and GetRandomLocation extraction are clean refactors.

CI Status

  • maui-pr: ✅ All stages pass (builds, Helix unit tests, integration tests)
  • Build Analysis: ✅ Pass

Devil's Advocate

  1. Could the PropertyChanged subscription cause threading issues? PropertyChanged fires on whatever thread sets the property. Map marker updates (marker.Position = ...) must happen on the main thread. If a pin's Location is set from a background thread, this could crash. However, MAUI's binding system typically dispatches property changes to the main thread, and changing map pins from background threads would be an existing problem. Low risk.

  2. Could PinOnPropertyChanged fire after the marker has been removed? If the pin is removed from the collection and MapPins fires, the old markers are Remove()d and _markers is nulled. If PropertyChanged fires between Remove() and the unsubscribe, _markers would be null → early return. Safe.

  3. Does the null! on _markers.Add(marker!) suppress a real null issue? No — marker was already null-checked by the ?? throw on the previous line. The ! is redundant but harmless.

  4. PublicAPI change: The PublicAPI.Unshipped.txt change is just a BOM addition (\u{feff}), not an API change. No new public API is exposed.

Verdict: LGTM with caveats

Confidence: high

Summary: Correct fix for a long-standing regression from Xamarin.Forms.Maps. The PropertyChanged subscription pattern is the right approach for propagating pin property changes to native markers. The main caveat is a potential memory leak when pins are removed from the collection individually (subscription not cleaned up for removed pins). This is a minor leak in practice (pins are lightweight) and can be addressed in a follow-up. CI is fully green. The iOS/Windows gap should be tracked separately.

@kubaflo kubaflo changed the base branch from main to inflight/current April 12, 2026 22:19
@kubaflo kubaflo merged commit 1869611 into dotnet:inflight/current Apr 12, 2026
31 checks passed
PureWeen pushed a commit that referenced this pull request Apr 14, 2026
<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) 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 the `MarkerOptions` object
when the Location property changed
The actual `Marker` object already added to the map was not being
updated, causing the pin to stay in its original location

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Description of change

* **Improved marker association logic**: Updated the `AddPins` method in
`MapHandler` to store marker references in the `MapPinHandler` for
future property updates, ensuring tighter integration between pins and
markers.

Validated the behaviour in the following platforms

- [x] Android
- [ ] Windows
- [ ] iOS
- [ ] Mac

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #12916

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

### Output
| Before| After|
|--|--|
| <video
src="https://github.com/user-attachments/assets/83bedab7-846b-41c1-872e-b6e0d0cd81a4">
| <video
src="https://github.com/user-attachments/assets/fd86fd38-6619-4cf9-999a-de9d05b21e17">
|

---------

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
devanathan-vaithiyanathan pushed a commit to Tamilarasan-Paranthaman/maui that referenced this pull request Apr 21, 2026
<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) 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 the `MarkerOptions` object
when the Location property changed
The actual `Marker` object already added to the map was not being
updated, causing the pin to stay in its original location

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Description of change

* **Improved marker association logic**: Updated the `AddPins` method in
`MapHandler` to store marker references in the `MapPinHandler` for
future property updates, ensuring tighter integration between pins and
markers.

Validated the behaviour in the following platforms

- [x] Android
- [ ] Windows
- [ ] iOS
- [ ] Mac

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes dotnet#12916

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

### Output
| Before| After|
|--|--|
| <video
src="https://github.com/user-attachments/assets/83bedab7-846b-41c1-872e-b6e0d0cd81a4">
| <video
src="https://github.com/user-attachments/assets/fd86fd38-6619-4cf9-999a-de9d05b21e17">
|

---------

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
PureWeen pushed a commit that referenced this pull request Apr 22, 2026
<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) 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 the `MarkerOptions` object
when the Location property changed
The actual `Marker` object already added to the map was not being
updated, causing the pin to stay in its original location

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Description of change

* **Improved marker association logic**: Updated the `AddPins` method in
`MapHandler` to store marker references in the `MapPinHandler` for
future property updates, ensuring tighter integration between pins and
markers.

Validated the behaviour in the following platforms

- [x] Android
- [ ] Windows
- [ ] iOS
- [ ] Mac

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #12916

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

### Output
| Before| After|
|--|--|
| <video
src="https://github.com/user-attachments/assets/83bedab7-846b-41c1-872e-b6e0d0cd81a4">
| <video
src="https://github.com/user-attachments/assets/fd86fd38-6619-4cf9-999a-de9d05b21e17">
|

---------

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
PureWeen pushed a commit that referenced this pull request Apr 28, 2026
<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) 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 the `MarkerOptions` object
when the Location property changed
The actual `Marker` object already added to the map was not being
updated, causing the pin to stay in its original location

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Description of change

* **Improved marker association logic**: Updated the `AddPins` method in
`MapHandler` to store marker references in the `MapPinHandler` for
future property updates, ensuring tighter integration between pins and
markers.

Validated the behaviour in the following platforms

- [x] Android
- [ ] Windows
- [ ] iOS
- [ ] Mac

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #12916

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

### Output
| Before| After|
|--|--|
| <video
src="https://github.com/user-attachments/assets/83bedab7-846b-41c1-872e-b6e0d0cd81a4">
| <video
src="https://github.com/user-attachments/assets/fd86fd38-6619-4cf9-999a-de9d05b21e17">
|

---------

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
PureWeen pushed a commit that referenced this pull request Apr 29, 2026
<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) 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 the `MarkerOptions` object
when the Location property changed
The actual `Marker` object already added to the map was not being
updated, causing the pin to stay in its original location

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Description of change

* **Improved marker association logic**: Updated the `AddPins` method in
`MapHandler` to store marker references in the `MapPinHandler` for
future property updates, ensuring tighter integration between pins and
markers.

Validated the behaviour in the following platforms

- [x] Android
- [ ] Windows
- [ ] iOS
- [ ] Mac

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #12916

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

### Output
| Before| After|
|--|--|
| <video
src="https://github.com/user-attachments/assets/83bedab7-846b-41c1-872e-b6e0d0cd81a4">
| <video
src="https://github.com/user-attachments/assets/fd86fd38-6619-4cf9-999a-de9d05b21e17">
|

---------

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-controls-map Map / Maps community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-fix-implemented PR author implemented the agent suggested fix s/agent-fix-pr-picked AI could not beat the PR fix - PR is the best among all candidates s/agent-gate-failed AI could not verify tests catch the bug s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Maps] [Regression from Xamarin.Forms.Maps] Changing Location on a Pin does nothing

7 participants