Add MapLongClicked event to Map control#33792
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a MapLongClicked event to the Map control and the corresponding IMap.LongClicked(Location) handler hook, enabling long-press location scenarios (e.g., “drop a pin here”) with Android and iOS/MacCatalyst implementations.
Changes:
- Introduces
Map.MapLongClickedandIMap.LongClicked(Location)public API surface. - Wires platform implementations: Google Maps
MapLongClick(Android) andUILongPressGestureRecognizer(iOS/MacCatalyst). - Adds unit tests and a new sample gallery page demonstrating the feature.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/Core/maps/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt | Adds new IMap.LongClicked(Location) API entry (netstandard). |
| src/Core/maps/src/PublicAPI/net/PublicAPI.Unshipped.txt | Adds new IMap.LongClicked(Location) API entry (net). |
| src/Core/maps/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt | Adds new IMap.LongClicked(Location) API entry (net-windows). |
| src/Core/maps/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt | Adds new IMap.LongClicked(Location) API entry (net-tizen). |
| src/Core/maps/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt | Adds new IMap.LongClicked(Location) API entry (net-maccatalyst). |
| src/Core/maps/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt | Adds new IMap.LongClicked(Location) API entry (net-ios). |
| src/Core/maps/src/PublicAPI/net-android/PublicAPI.Unshipped.txt | Adds new IMap.LongClicked(Location) API entry (net-android). |
| src/Core/maps/src/Platform/iOS/MauiMKMapView.cs | Adds iOS/MacCatalyst long-press gesture recognizer and routes to VirtualView.LongClicked(...). |
| src/Core/maps/src/Handlers/Map/MapHandler.Android.cs | Subscribes/unsubscribes to GoogleMap MapLongClick and routes to VirtualView.LongClicked(...). |
| src/Core/maps/src/Core/IMap.cs | Adds LongClicked(Location) to the handler-facing map interface. |
| src/Controls/Maps/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt | Adds new Map.MapLongClicked event API entry (netstandard). |
| src/Controls/Maps/src/PublicAPI/net/PublicAPI.Unshipped.txt | Adds new Map.MapLongClicked event API entry (net). |
| src/Controls/Maps/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt | Adds new Map.MapLongClicked event API entry (net-windows). |
| src/Controls/Maps/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt | Adds new Map.MapLongClicked event API entry (net-tizen). |
| src/Controls/Maps/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt | Adds new Map.MapLongClicked event API entry (net-maccatalyst). |
| src/Controls/Maps/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt | Adds new Map.MapLongClicked event API entry (net-ios). |
| src/Controls/Maps/src/PublicAPI/net-android/PublicAPI.Unshipped.txt | Adds new Map.MapLongClicked event API entry (net-android). |
| src/Controls/Maps/src/Map.cs | Declares the new MapLongClicked event on the control. |
| src/Controls/Maps/src/HandlerImpl/Map.Impl.cs | Implements IMap.LongClicked(...) to raise MapLongClicked. |
| src/Controls/tests/Core.UnitTests/MapTests.cs | Adds unit tests validating event raising semantics and handler add/remove behavior. |
| src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/MapsGallery.cs | Adds navigation entry for the new sample gallery. |
| src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/MapLongClickGallery.xaml.cs | New sample page code-behind demonstrating adding pins on long press. |
| src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/MapLongClickGallery.xaml | New sample UI wiring MapLongClicked to the handler. |
|
/rebase |
1c31deb to
f22654f
Compare
f22654f to
28552bb
Compare
92b6a8b to
cba937b
Compare
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/azp run maui-pr |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Independent Code ReviewSummary: Adds ✅ What Looks Good
🔴 Issues1. Reuses 2. No Windows implementation 🟡 Nits
|
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 33792Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 33792" |
|
Thanks for the review @kubaflo! Responses: 1. Reuses MapClickedEventArgs instead of a dedicated type 2. No Windows implementation 3. Nullable correctness in tests |
🔍 Round 2 Review — PR #33792 (Map.MapLongClicked)Updated with author response analysis ✅ Fixed Since Round 1
|
|
/azp run maui-pr |
|
Azure Pipelines successfully started running 1 pipeline(s). |
📋 Round 3 — PR #33792 (Map.MapLongClicked) — Final RecommendationNo outstanding issues. All Round 2 concerns were satisfactorily addressed. Recommendation: Merge when CI passes. Clean and ready. The |
- Add LongClicked(Location) method to IMap interface - Add MapLongClicked event to Map class - Implement IMap.LongClicked in Map.Impl.cs - Add Android support via MapLongClick event handler - Add iOS support via UILongPressGestureRecognizer - Add unit tests for MapLongClicked event - Add MapLongClickGallery sample page - Update PublicAPI.Unshipped.txt files
- Add test for MapClicked and MapLongClicked coexistence - Add test for no-handler case (doesn't throw) - Add test for multiple handlers all firing - Add test for handler removal
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
0d7ba31 to
d1dfc1b
Compare
|
🚨 API change(s) detected @davidortinau FYI |
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!
Description of Change
Adds a
MapLongClickedevent to the Map control that fires when the user performs a long press/hold gesture on the map. This is a common pattern for "add pin at location" scenarios.Platforms Implemented
MapLongClickevent from Google Maps SDKUILongPressGestureRecognizerwith proper state filteringImplementation Details
State == Began)ShouldReceiveTouch)MapClickedevent without interferenceMapClickedEventArgsclassPublic API Changes
Usage Example
Testing
MapLongClickGallery)Related
Part of Maps Epic: #33787