Add Circle, Polygon, and Polyline click events for Map control#29101
Merged
jfversluis merged 2 commits intodotnet:net11.0from Feb 26, 2026
Merged
Add Circle, Polygon, and Polyline click events for Map control#29101jfversluis merged 2 commits intodotnet:net11.0from
jfversluis merged 2 commits intodotnet:net11.0from
Conversation
Contributor
|
Hey there @@kubaflo! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
17f6f65 to
b9ce465
Compare
25 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds click/tap event support for Circle, Polygon, and Polyline map elements in the .NET MAUI Map control, addressing issue #28825. The implementation is cross-platform (Android, iOS/MacCatalyst) with proper unit tests and a sample gallery page demonstrating the functionality.
Changes:
- Added
IMapElement.Clicked()interface method to enable click event handling across all map elements - Implemented platform-specific click detection using native listeners on Android and hit testing on iOS/MacCatalyst
- Added three new public events:
CircleClicked,PolygonClicked, andPolylineClickedwith correspondingEventHandlersignatures
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Core/maps/src/Core/IMapElement.cs | Added Clicked() method to interface for click event propagation |
| src/Core/maps/src/Handlers/Map/MapHandler.Android.cs | Implemented Android click listeners and registered them with GoogleMap |
| src/Core/maps/src/Platform/iOS/MauiMKMapView.cs | Added iOS/MacCatalyst hit testing logic for circles, polygons, and polylines |
| src/Controls/Maps/src/Circle.cs | Added CircleClicked event and implementation of IMapElement.Clicked() |
| src/Controls/Maps/src/Polygon.cs | Added PolygonClicked event and implementation of IMapElement.Clicked() |
| src/Controls/Maps/src/Polyline.cs | Added PolylineClicked event and implementation of IMapElement.Clicked() |
| src/Controls/Maps/src/HandlerImpl/MapElement.Impl.cs | Added stub implementation throwing NotImplementedException |
| src/Controls/tests/Core.UnitTests/MapTests.cs | Added 6 unit tests verifying click events fire correctly and sender is correct |
| src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/MapElementClickGallery.xaml | Added sample page XAML with map and status label |
| src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/MapElementClickGallery.xaml.cs | Added sample page implementation demonstrating all three click events |
| src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/MapsGallery.cs | Added navigation button to new gallery page |
| PublicAPI.Unshipped.txt files (multiple) | Added API entries for IMapElement.Clicked() and event properties |
This was referenced Jan 30, 2026
Open
Member
|
/rebase |
b9ce465 to
2e8c829
Compare
- Add CircleClicked, PolygonClicked, PolylineClicked events - Implement IMapElement.Clicked() for all map elements - Add Android click listeners (IOnCircleClickListener, IOnPolygonClickListener, IOnPolylineClickListener) - Add iOS hit testing for circle, polygon, and polyline clicks - Add MapElementClickGallery sample page - Add unit tests for click events - Update PublicAPI.Unshipped.txt files Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
66f7eb3 to
7e2dbaf
Compare
jfversluis
previously approved these changes
Feb 25, 2026
…y priority - Use Math.Max(renderer.LineWidth, 44) for polyline hit testing instead of conditioning on StrokeColor. This ensures a minimum 44pt tap target while respecting larger line widths. - Document the overlay hit-test priority order (Circle > Polygon > Polyline) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
7e2dbaf to
7e3e0fd
Compare
jfversluis
approved these changes
Feb 26, 2026
PureWeen
added a commit
that referenced
this pull request
Feb 27, 2026
…4260) This PR merges commits from `net11.0` into `release/11.0.1xx-preview2`. Commits include: - Add Circle, Polygon, and Polyline click events for Map control (#29101) - [automated] Merge branch 'main' => 'net11.0' (#34203) - Fix empty string binding to nullable value types (#33536) - Add MapElement.IsVisible and MapElement.ZIndex properties (#33993) - Add MauiXamlHotReload property for IDE communication (#34028) ## Instructions for merging Complete this PR by creating a **merge commit**, *not* a squash or rebase commit.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
This PR adds support for detecting click interactions on Circle, Polygon, and Polyline elements within the .NET MAUI Map control.
Enhancements over original proposal:
PolylineClickedevent (in addition to Circle and Polygon)MapElementClickGallery)Platforms Affected
IOnCircleClickListener,IOnPolygonClickListener,IOnPolylineClickListenerPublic API Changes
Issues Fixed
Fixes #28825
Original Proposal
Demo
Screen.Recording.2025-04-21.at.14.52.42.mov
Screen.Recording.2025-04-21.at.14.51.33.mov
Co-authored-by: Jakub Florkowski kubaflo123@gmail.com