diff --git a/src/Controls/Maps/src/Circle.cs b/src/Controls/Maps/src/Circle.cs index a33ac2c4e154..d07785908df2 100644 --- a/src/Controls/Maps/src/Circle.cs +++ b/src/Controls/Maps/src/Circle.cs @@ -1,3 +1,4 @@ +using System; using Microsoft.Maui.Devices.Sensors; using Microsoft.Maui.Graphics; using Microsoft.Maui.Maps; @@ -56,5 +57,16 @@ public Color FillColor get => (Color)GetValue(FillColorProperty); set => SetValue(FillColorProperty, value); } + + /// + /// Occurs when the user clicks/taps on the circle element + /// + public event EventHandler? CircleClicked; + + void IMapElement.Clicked() + { + CircleClicked?.Invoke(this, EventArgs.Empty); + } + } } diff --git a/src/Controls/Maps/src/HandlerImpl/MapElement.Impl.cs b/src/Controls/Maps/src/HandlerImpl/MapElement.Impl.cs index a7df3ff2d211..fab67d2cf4e0 100644 --- a/src/Controls/Maps/src/HandlerImpl/MapElement.Impl.cs +++ b/src/Controls/Maps/src/HandlerImpl/MapElement.Impl.cs @@ -19,5 +19,7 @@ public partial class MapElement : IMapElement float IStroke.StrokeDashOffset => throw new NotImplementedException(); float IStroke.StrokeMiterLimit => throw new NotImplementedException(); + + void IMapElement.Clicked() => throw new NotImplementedException(); } } diff --git a/src/Controls/Maps/src/Polygon.cs b/src/Controls/Maps/src/Polygon.cs index 99eabdd222d5..71e85efa8895 100644 --- a/src/Controls/Maps/src/Polygon.cs +++ b/src/Controls/Maps/src/Polygon.cs @@ -1,7 +1,9 @@ +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using Microsoft.Maui.Devices.Sensors; using Microsoft.Maui.Graphics; +using Microsoft.Maui.Maps; namespace Microsoft.Maui.Controls.Maps { @@ -31,6 +33,16 @@ public Color FillColor /// public IList Geopath { get; } + /// + /// Occurs when the user clicks/taps on the polygon element + /// + public event EventHandler? PolygonClicked; + + void IMapElement.Clicked() + { + PolygonClicked?.Invoke(this, EventArgs.Empty); + } + /// /// Initializes a new instance of the class. /// diff --git a/src/Controls/Maps/src/Polyline.cs b/src/Controls/Maps/src/Polyline.cs index 3f5029182fb9..2337238c1f98 100644 --- a/src/Controls/Maps/src/Polyline.cs +++ b/src/Controls/Maps/src/Polyline.cs @@ -1,6 +1,8 @@ +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using Microsoft.Maui.Devices.Sensors; +using Microsoft.Maui.Maps; namespace Microsoft.Maui.Controls.Maps { @@ -14,6 +16,16 @@ public partial class Polyline : MapElement /// public IList Geopath { get; } + /// + /// Occurs when the user clicks/taps on the polyline element + /// + public event EventHandler? PolylineClicked; + + void IMapElement.Clicked() + { + PolylineClicked?.Invoke(this, EventArgs.Empty); + } + /// /// Initializes a new instance of the class. /// diff --git a/src/Controls/Maps/src/PublicAPI/net-android/PublicAPI.Unshipped.txt b/src/Controls/Maps/src/PublicAPI/net-android/PublicAPI.Unshipped.txt index 90a0ef71d1ea..5b49a0a43882 100644 --- a/src/Controls/Maps/src/PublicAPI/net-android/PublicAPI.Unshipped.txt +++ b/src/Controls/Maps/src/PublicAPI/net-android/PublicAPI.Unshipped.txt @@ -1,11 +1,14 @@ -#nullable enable +#nullable enable +Microsoft.Maui.Controls.Maps.Circle.CircleClicked -> System.EventHandler? +Microsoft.Maui.Controls.Maps.Map.Region.get -> Microsoft.Maui.Maps.MapSpan? +Microsoft.Maui.Controls.Maps.Map.Region.set -> void Microsoft.Maui.Controls.Maps.MapElement.IsVisible.get -> bool Microsoft.Maui.Controls.Maps.MapElement.IsVisible.set -> void Microsoft.Maui.Controls.Maps.MapElement.ZIndex.get -> int Microsoft.Maui.Controls.Maps.MapElement.ZIndex.set -> void +Microsoft.Maui.Controls.Maps.Polygon.PolygonClicked -> System.EventHandler? +Microsoft.Maui.Controls.Maps.Polyline.PolylineClicked -> System.EventHandler? +static readonly Microsoft.Maui.Controls.Maps.Map.RegionProperty -> Microsoft.Maui.Controls.BindableProperty! static readonly Microsoft.Maui.Controls.Maps.MapElement.IsVisibleProperty -> Microsoft.Maui.Controls.BindableProperty! static readonly Microsoft.Maui.Controls.Maps.MapElement.ZIndexProperty -> Microsoft.Maui.Controls.BindableProperty! -static readonly Microsoft.Maui.Controls.Maps.Map.RegionProperty -> Microsoft.Maui.Controls.BindableProperty! -Microsoft.Maui.Controls.Maps.Map.Region.get -> Microsoft.Maui.Maps.MapSpan? -Microsoft.Maui.Controls.Maps.Map.Region.set -> void diff --git a/src/Controls/Maps/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt b/src/Controls/Maps/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt index 90a0ef71d1ea..5b49a0a43882 100644 --- a/src/Controls/Maps/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt +++ b/src/Controls/Maps/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt @@ -1,11 +1,14 @@ -#nullable enable +#nullable enable +Microsoft.Maui.Controls.Maps.Circle.CircleClicked -> System.EventHandler? +Microsoft.Maui.Controls.Maps.Map.Region.get -> Microsoft.Maui.Maps.MapSpan? +Microsoft.Maui.Controls.Maps.Map.Region.set -> void Microsoft.Maui.Controls.Maps.MapElement.IsVisible.get -> bool Microsoft.Maui.Controls.Maps.MapElement.IsVisible.set -> void Microsoft.Maui.Controls.Maps.MapElement.ZIndex.get -> int Microsoft.Maui.Controls.Maps.MapElement.ZIndex.set -> void +Microsoft.Maui.Controls.Maps.Polygon.PolygonClicked -> System.EventHandler? +Microsoft.Maui.Controls.Maps.Polyline.PolylineClicked -> System.EventHandler? +static readonly Microsoft.Maui.Controls.Maps.Map.RegionProperty -> Microsoft.Maui.Controls.BindableProperty! static readonly Microsoft.Maui.Controls.Maps.MapElement.IsVisibleProperty -> Microsoft.Maui.Controls.BindableProperty! static readonly Microsoft.Maui.Controls.Maps.MapElement.ZIndexProperty -> Microsoft.Maui.Controls.BindableProperty! -static readonly Microsoft.Maui.Controls.Maps.Map.RegionProperty -> Microsoft.Maui.Controls.BindableProperty! -Microsoft.Maui.Controls.Maps.Map.Region.get -> Microsoft.Maui.Maps.MapSpan? -Microsoft.Maui.Controls.Maps.Map.Region.set -> void diff --git a/src/Controls/Maps/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt b/src/Controls/Maps/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt index 90a0ef71d1ea..5b49a0a43882 100644 --- a/src/Controls/Maps/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt +++ b/src/Controls/Maps/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt @@ -1,11 +1,14 @@ -#nullable enable +#nullable enable +Microsoft.Maui.Controls.Maps.Circle.CircleClicked -> System.EventHandler? +Microsoft.Maui.Controls.Maps.Map.Region.get -> Microsoft.Maui.Maps.MapSpan? +Microsoft.Maui.Controls.Maps.Map.Region.set -> void Microsoft.Maui.Controls.Maps.MapElement.IsVisible.get -> bool Microsoft.Maui.Controls.Maps.MapElement.IsVisible.set -> void Microsoft.Maui.Controls.Maps.MapElement.ZIndex.get -> int Microsoft.Maui.Controls.Maps.MapElement.ZIndex.set -> void +Microsoft.Maui.Controls.Maps.Polygon.PolygonClicked -> System.EventHandler? +Microsoft.Maui.Controls.Maps.Polyline.PolylineClicked -> System.EventHandler? +static readonly Microsoft.Maui.Controls.Maps.Map.RegionProperty -> Microsoft.Maui.Controls.BindableProperty! static readonly Microsoft.Maui.Controls.Maps.MapElement.IsVisibleProperty -> Microsoft.Maui.Controls.BindableProperty! static readonly Microsoft.Maui.Controls.Maps.MapElement.ZIndexProperty -> Microsoft.Maui.Controls.BindableProperty! -static readonly Microsoft.Maui.Controls.Maps.Map.RegionProperty -> Microsoft.Maui.Controls.BindableProperty! -Microsoft.Maui.Controls.Maps.Map.Region.get -> Microsoft.Maui.Maps.MapSpan? -Microsoft.Maui.Controls.Maps.Map.Region.set -> void diff --git a/src/Controls/Maps/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt b/src/Controls/Maps/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt index 90a0ef71d1ea..5b49a0a43882 100644 --- a/src/Controls/Maps/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt +++ b/src/Controls/Maps/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt @@ -1,11 +1,14 @@ -#nullable enable +#nullable enable +Microsoft.Maui.Controls.Maps.Circle.CircleClicked -> System.EventHandler? +Microsoft.Maui.Controls.Maps.Map.Region.get -> Microsoft.Maui.Maps.MapSpan? +Microsoft.Maui.Controls.Maps.Map.Region.set -> void Microsoft.Maui.Controls.Maps.MapElement.IsVisible.get -> bool Microsoft.Maui.Controls.Maps.MapElement.IsVisible.set -> void Microsoft.Maui.Controls.Maps.MapElement.ZIndex.get -> int Microsoft.Maui.Controls.Maps.MapElement.ZIndex.set -> void +Microsoft.Maui.Controls.Maps.Polygon.PolygonClicked -> System.EventHandler? +Microsoft.Maui.Controls.Maps.Polyline.PolylineClicked -> System.EventHandler? +static readonly Microsoft.Maui.Controls.Maps.Map.RegionProperty -> Microsoft.Maui.Controls.BindableProperty! static readonly Microsoft.Maui.Controls.Maps.MapElement.IsVisibleProperty -> Microsoft.Maui.Controls.BindableProperty! static readonly Microsoft.Maui.Controls.Maps.MapElement.ZIndexProperty -> Microsoft.Maui.Controls.BindableProperty! -static readonly Microsoft.Maui.Controls.Maps.Map.RegionProperty -> Microsoft.Maui.Controls.BindableProperty! -Microsoft.Maui.Controls.Maps.Map.Region.get -> Microsoft.Maui.Maps.MapSpan? -Microsoft.Maui.Controls.Maps.Map.Region.set -> void diff --git a/src/Controls/Maps/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt b/src/Controls/Maps/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt index 90a0ef71d1ea..5b49a0a43882 100644 --- a/src/Controls/Maps/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt +++ b/src/Controls/Maps/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt @@ -1,11 +1,14 @@ -#nullable enable +#nullable enable +Microsoft.Maui.Controls.Maps.Circle.CircleClicked -> System.EventHandler? +Microsoft.Maui.Controls.Maps.Map.Region.get -> Microsoft.Maui.Maps.MapSpan? +Microsoft.Maui.Controls.Maps.Map.Region.set -> void Microsoft.Maui.Controls.Maps.MapElement.IsVisible.get -> bool Microsoft.Maui.Controls.Maps.MapElement.IsVisible.set -> void Microsoft.Maui.Controls.Maps.MapElement.ZIndex.get -> int Microsoft.Maui.Controls.Maps.MapElement.ZIndex.set -> void +Microsoft.Maui.Controls.Maps.Polygon.PolygonClicked -> System.EventHandler? +Microsoft.Maui.Controls.Maps.Polyline.PolylineClicked -> System.EventHandler? +static readonly Microsoft.Maui.Controls.Maps.Map.RegionProperty -> Microsoft.Maui.Controls.BindableProperty! static readonly Microsoft.Maui.Controls.Maps.MapElement.IsVisibleProperty -> Microsoft.Maui.Controls.BindableProperty! static readonly Microsoft.Maui.Controls.Maps.MapElement.ZIndexProperty -> Microsoft.Maui.Controls.BindableProperty! -static readonly Microsoft.Maui.Controls.Maps.Map.RegionProperty -> Microsoft.Maui.Controls.BindableProperty! -Microsoft.Maui.Controls.Maps.Map.Region.get -> Microsoft.Maui.Maps.MapSpan? -Microsoft.Maui.Controls.Maps.Map.Region.set -> void diff --git a/src/Controls/Maps/src/PublicAPI/net/PublicAPI.Unshipped.txt b/src/Controls/Maps/src/PublicAPI/net/PublicAPI.Unshipped.txt index 90a0ef71d1ea..5b49a0a43882 100644 --- a/src/Controls/Maps/src/PublicAPI/net/PublicAPI.Unshipped.txt +++ b/src/Controls/Maps/src/PublicAPI/net/PublicAPI.Unshipped.txt @@ -1,11 +1,14 @@ -#nullable enable +#nullable enable +Microsoft.Maui.Controls.Maps.Circle.CircleClicked -> System.EventHandler? +Microsoft.Maui.Controls.Maps.Map.Region.get -> Microsoft.Maui.Maps.MapSpan? +Microsoft.Maui.Controls.Maps.Map.Region.set -> void Microsoft.Maui.Controls.Maps.MapElement.IsVisible.get -> bool Microsoft.Maui.Controls.Maps.MapElement.IsVisible.set -> void Microsoft.Maui.Controls.Maps.MapElement.ZIndex.get -> int Microsoft.Maui.Controls.Maps.MapElement.ZIndex.set -> void +Microsoft.Maui.Controls.Maps.Polygon.PolygonClicked -> System.EventHandler? +Microsoft.Maui.Controls.Maps.Polyline.PolylineClicked -> System.EventHandler? +static readonly Microsoft.Maui.Controls.Maps.Map.RegionProperty -> Microsoft.Maui.Controls.BindableProperty! static readonly Microsoft.Maui.Controls.Maps.MapElement.IsVisibleProperty -> Microsoft.Maui.Controls.BindableProperty! static readonly Microsoft.Maui.Controls.Maps.MapElement.ZIndexProperty -> Microsoft.Maui.Controls.BindableProperty! -static readonly Microsoft.Maui.Controls.Maps.Map.RegionProperty -> Microsoft.Maui.Controls.BindableProperty! -Microsoft.Maui.Controls.Maps.Map.Region.get -> Microsoft.Maui.Maps.MapSpan? -Microsoft.Maui.Controls.Maps.Map.Region.set -> void diff --git a/src/Controls/Maps/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt b/src/Controls/Maps/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt index 90a0ef71d1ea..5b49a0a43882 100644 --- a/src/Controls/Maps/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt +++ b/src/Controls/Maps/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt @@ -1,11 +1,14 @@ -#nullable enable +#nullable enable +Microsoft.Maui.Controls.Maps.Circle.CircleClicked -> System.EventHandler? +Microsoft.Maui.Controls.Maps.Map.Region.get -> Microsoft.Maui.Maps.MapSpan? +Microsoft.Maui.Controls.Maps.Map.Region.set -> void Microsoft.Maui.Controls.Maps.MapElement.IsVisible.get -> bool Microsoft.Maui.Controls.Maps.MapElement.IsVisible.set -> void Microsoft.Maui.Controls.Maps.MapElement.ZIndex.get -> int Microsoft.Maui.Controls.Maps.MapElement.ZIndex.set -> void +Microsoft.Maui.Controls.Maps.Polygon.PolygonClicked -> System.EventHandler? +Microsoft.Maui.Controls.Maps.Polyline.PolylineClicked -> System.EventHandler? +static readonly Microsoft.Maui.Controls.Maps.Map.RegionProperty -> Microsoft.Maui.Controls.BindableProperty! static readonly Microsoft.Maui.Controls.Maps.MapElement.IsVisibleProperty -> Microsoft.Maui.Controls.BindableProperty! static readonly Microsoft.Maui.Controls.Maps.MapElement.ZIndexProperty -> Microsoft.Maui.Controls.BindableProperty! -static readonly Microsoft.Maui.Controls.Maps.Map.RegionProperty -> Microsoft.Maui.Controls.BindableProperty! -Microsoft.Maui.Controls.Maps.Map.Region.get -> Microsoft.Maui.Maps.MapSpan? -Microsoft.Maui.Controls.Maps.Map.Region.set -> void diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/MapElementClickGallery.xaml b/src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/MapElementClickGallery.xaml new file mode 100644 index 000000000000..907be9b8f4b9 --- /dev/null +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/MapElementClickGallery.xaml @@ -0,0 +1,32 @@ + + + + + diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/MapElementClickGallery.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/MapElementClickGallery.xaml.cs new file mode 100644 index 000000000000..457475c48196 --- /dev/null +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/MapElementClickGallery.xaml.cs @@ -0,0 +1,77 @@ +using System; +using Microsoft.Maui.Controls; +using Microsoft.Maui.Controls.Maps; +using Microsoft.Maui.Graphics; +using Microsoft.Maui.Maps; +using Position = Microsoft.Maui.Devices.Sensors.Location; + +namespace Maui.Controls.Sample.Pages.MapsGalleries +{ + public partial class MapElementClickGallery : ContentPage + { + public MapElementClickGallery() + { + InitializeComponent(); + AddMapElements(); + } + + void AddMapElements() + { + // Add a circle + var circle = new Circle + { + Center = new Position(37.79752, -122.40183), + Radius = new Distance(200), + StrokeColor = Color.FromArgb("#88FF0000"), + StrokeWidth = 8, + FillColor = Color.FromArgb("#88FFC0CB") + }; + circle.CircleClicked += OnCircleClicked; + map.MapElements.Add(circle); + + // Add a polygon (triangle) + var polygon = new Polygon + { + StrokeColor = Color.FromArgb("#880000FF"), + StrokeWidth = 8, + FillColor = Color.FromArgb("#8800FF00") + }; + polygon.Geopath.Add(new Position(37.7997, -122.4050)); + polygon.Geopath.Add(new Position(37.7997, -122.3980)); + polygon.Geopath.Add(new Position(37.7950, -122.4015)); + polygon.PolygonClicked += OnPolygonClicked; + map.MapElements.Add(polygon); + + // Add a polyline + var polyline = new Polyline + { + StrokeColor = Color.FromArgb("#FF6600"), + StrokeWidth = 10 + }; + polyline.Geopath.Add(new Position(37.7930, -122.4100)); + polyline.Geopath.Add(new Position(37.7940, -122.4050)); + polyline.Geopath.Add(new Position(37.7935, -122.4000)); + polyline.Geopath.Add(new Position(37.7950, -122.3950)); + polyline.PolylineClicked += OnPolylineClicked; + map.MapElements.Add(polyline); + } + + void OnCircleClicked(object? sender, EventArgs e) + { + StatusLabel.Text = "Circle clicked!"; + StatusLabel.TextColor = Colors.Red; + } + + void OnPolygonClicked(object? sender, EventArgs e) + { + StatusLabel.Text = "Polygon clicked!"; + StatusLabel.TextColor = Colors.Green; + } + + void OnPolylineClicked(object? sender, EventArgs e) + { + StatusLabel.Text = "Polyline clicked!"; + StatusLabel.TextColor = Colors.Orange; + } + } +} diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/MapsGallery.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/MapsGallery.cs index 594a21829caa..5241116db69e 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/MapsGallery.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/MapsGallery.cs @@ -20,6 +20,7 @@ public MapsGallery() GalleryBuilder.NavButton("Circle", () => new CircleGallery(), Navigation), GalleryBuilder.NavButton("Polygon", () => new PolygonsGallery(), Navigation), GalleryBuilder.NavButton("Element Visibility & ZIndex", () => new MapElementVisibilityGallery(), Navigation), + GalleryBuilder.NavButton("MapElement Click Events", () => new MapElementClickGallery(), Navigation), } } }; diff --git a/src/Controls/tests/Core.UnitTests/MapTests.cs b/src/Controls/tests/Core.UnitTests/MapTests.cs index 566eef8fc451..b796710e3aa0 100644 --- a/src/Controls/tests/Core.UnitTests/MapTests.cs +++ b/src/Controls/tests/Core.UnitTests/MapTests.cs @@ -528,5 +528,96 @@ public MockViewModel(IEnumerable itemsSource) Items = itemsSource; } } + + [Fact] + public void CircleClickedEventFires() + { + var circle = new Circle + { + Center = new Location(37.79752, -122.40183), + Radius = new Distance(200), + }; + + bool eventFired = false; + circle.CircleClicked += (s, e) => eventFired = true; + + ((IMapElement)circle).Clicked(); + + Assert.True(eventFired); + } + + [Fact] + public void PolygonClickedEventFires() + { + var polygon = new Polygon(); + polygon.Geopath.Add(new Location(37.7997, -122.4050)); + polygon.Geopath.Add(new Location(37.7997, -122.3980)); + polygon.Geopath.Add(new Location(37.7950, -122.4015)); + + bool eventFired = false; + polygon.PolygonClicked += (s, e) => eventFired = true; + + ((IMapElement)polygon).Clicked(); + + Assert.True(eventFired); + } + + [Fact] + public void PolylineClickedEventFires() + { + var polyline = new Polyline(); + polyline.Geopath.Add(new Location(37.7930, -122.4100)); + polyline.Geopath.Add(new Location(37.7940, -122.4050)); + + bool eventFired = false; + polyline.PolylineClicked += (s, e) => eventFired = true; + + ((IMapElement)polyline).Clicked(); + + Assert.True(eventFired); + } + + [Fact] + public void CircleClickedEventSenderIsCircle() + { + var circle = new Circle + { + Center = new Location(37.79752, -122.40183), + Radius = new Distance(200), + }; + + object sender = null; + circle.CircleClicked += (s, e) => sender = s; + + ((IMapElement)circle).Clicked(); + + Assert.Same(circle, sender); + } + + [Fact] + public void PolygonClickedEventSenderIsPolygon() + { + var polygon = new Polygon(); + + object sender = null; + polygon.PolygonClicked += (s, e) => sender = s; + + ((IMapElement)polygon).Clicked(); + + Assert.Same(polygon, sender); + } + + [Fact] + public void PolylineClickedEventSenderIsPolyline() + { + var polyline = new Polyline(); + + object sender = null; + polyline.PolylineClicked += (s, e) => sender = s; + + ((IMapElement)polyline).Clicked(); + + Assert.Same(polyline, sender); + } } } diff --git a/src/Core/maps/src/Core/IMapElement.cs b/src/Core/maps/src/Core/IMapElement.cs index c9815403af4f..cbe3824652ad 100644 --- a/src/Core/maps/src/Core/IMapElement.cs +++ b/src/Core/maps/src/Core/IMapElement.cs @@ -20,5 +20,10 @@ public interface IMapElement : IElement, IStroke /// Higher values are drawn on top of lower values. /// int ZIndex { get; } + + /// + /// Method called by the handler when user clicks on the element. + /// + void Clicked(); } } diff --git a/src/Core/maps/src/Handlers/Map/MapHandler.Android.cs b/src/Core/maps/src/Handlers/Map/MapHandler.Android.cs index b34fcbfd6dfd..14f48081c807 100644 --- a/src/Core/maps/src/Handlers/Map/MapHandler.Android.cs +++ b/src/Core/maps/src/Handlers/Map/MapHandler.Android.cs @@ -62,6 +62,9 @@ protected override void DisconnectHandler(MapView platformView) if (Map != null) { Map.SetOnCameraMoveListener(null); + Map.SetOnPolygonClickListener(null); + Map.SetOnCircleClickListener(null); + Map.SetOnPolylineClickListener(null); Map.MarkerClick -= OnMarkerClick; Map.InfoWindowClick -= OnInfoWindowClick; Map.MapClick -= OnMapClick; @@ -300,6 +303,9 @@ internal void OnMapReady(GoogleMap map) Map = map; map.SetOnCameraMoveListener(_mapReady); + map.SetOnPolygonClickListener(_mapReady); + map.SetOnCircleClickListener(_mapReady); + map.SetOnPolylineClickListener(_mapReady); map.MarkerClick += OnMarkerClick; map.InfoWindowClick += OnInfoWindowClick; @@ -546,6 +552,7 @@ void AddPolyline(IGeoPathMapElement polyline) var nativePolyline = map.AddPolyline(options); polyline.MapElementId = nativePolyline.Id; + nativePolyline.Clickable = true; if (polyline is IMapElement mapElement) { @@ -574,6 +581,7 @@ void AddPolygon(IGeoPathMapElement polygon) var nativePolygon = map.AddPolygon(options); polygon.MapElementId = nativePolygon.Id; + nativePolygon.Clickable = true; if (polygon is IMapElement mapElement) { @@ -601,6 +609,7 @@ void AddCircle(ICircleMapElement circle) var nativeCircle = map.AddCircle(options); circle.MapElementId = nativeCircle.Id; + nativeCircle.Clickable = true; if (circle is IMapElement mapElement) { @@ -612,7 +621,7 @@ void AddCircle(ICircleMapElement circle) } } - class MapCallbackHandler : Java.Lang.Object, GoogleMap.IOnCameraMoveListener, IOnMapReadyCallback + class MapCallbackHandler : Java.Lang.Object, GoogleMap.IOnCameraMoveListener, IOnMapReadyCallback, GoogleMap.IOnPolygonClickListener, GoogleMap.IOnCircleClickListener, GoogleMap.IOnPolylineClickListener { MapHandler? _handler; GoogleMap? _googleMap; @@ -646,6 +655,18 @@ protected override void Dispose(bool disposing) base.Dispose(disposing); } + + public void OnCircleClick(ACircle circle) => SendElementClickEvent(circle.Id); + + public void OnPolygonClick(APolygon polygon) => SendElementClickEvent(polygon.Id); + + public void OnPolylineClick(APolyline polyline) => SendElementClickEvent(polyline.Id); + + void SendElementClickEvent(string elementId) + { + var element = _handler?.VirtualView.Elements.FirstOrDefault(x => x.MapElementId?.ToString() == elementId); + element?.Clicked(); + } } } diff --git a/src/Core/maps/src/Platform/iOS/MauiMKMapView.cs b/src/Core/maps/src/Platform/iOS/MauiMKMapView.cs index 9c2137dee456..bdb3c383c22d 100644 --- a/src/Core/maps/src/Platform/iOS/MauiMKMapView.cs +++ b/src/Core/maps/src/Platform/iOS/MauiMKMapView.cs @@ -334,6 +334,67 @@ static void OnMapClicked(UITapGestureRecognizer recognizer) if (mauiMkMapView._handlerRef.TryGetTarget(out IMapHandler? handler)) handler?.VirtualView.Clicked(new Devices.Sensors.Location(tapGPS.Latitude, tapGPS.Longitude)); + + void SendClickEvent(IMKOverlay overlay) + { + handler?.VirtualView.Elements + .FirstOrDefault(x => x.MapElementId == overlay)? + .Clicked(); + } + + // Hit-test overlays in order: Circle > Polygon > Polyline (first match wins) + foreach (var overlay in mauiMkMapView.Overlays) + { + if (overlay is MKCircle circle) + { + var center = new CLLocation(circle.Coordinate.Latitude, circle.Coordinate.Longitude); + var touch = new CLLocation(tapGPS.Latitude, tapGPS.Longitude); + var distance = center.DistanceFrom(touch); + + if (distance <= circle.Radius) + { + SendClickEvent(overlay); + break; + } + } + else if (overlay is MKPolygon polygon) + { + var tapCoord = new CLLocationCoordinate2D(tapGPS.Latitude, tapGPS.Longitude); + var renderer = mauiMkMapView.GetViewForOverlayDelegate(mauiMkMapView, polygon) as MKPolygonRenderer; + + if (renderer?.Path is not null) + { + var mapPoint = MKMapPoint.FromCoordinate(tapCoord); + var pointInRenderer = renderer.PointForMapPoint(mapPoint); + + if (renderer.Path.ContainsPoint(pointInRenderer, true)) + { + SendClickEvent(overlay); + break; + } + } + } + else if (overlay is MKPolyline polyline) + { + var renderer = mauiMkMapView.GetViewForOverlayDelegate(mauiMkMapView, polyline) as MKPolylineRenderer; + + if (renderer?.Path is not null) + { + var tapCoord = new CLLocationCoordinate2D(tapGPS.Latitude, tapGPS.Longitude); + var mapPoint = MKMapPoint.FromCoordinate(tapCoord); + var pointInRenderer = renderer.PointForMapPoint(mapPoint); + + // Use a minimum tap target width for easier polyline interaction + var hitTestWidth = renderer.LineWidth < 44 ? (nfloat)44 : renderer.LineWidth; + using var strokedPath = renderer.Path.CopyByStrokingPath(hitTestWidth, CoreGraphics.CGLineCap.Round, CoreGraphics.CGLineJoin.Round, 1); + if (strokedPath?.ContainsPoint(pointInRenderer, true) == true) + { + SendClickEvent(overlay); + break; + } + } + } + } } } } diff --git a/src/Core/maps/src/PublicAPI/net-android/PublicAPI.Unshipped.txt b/src/Core/maps/src/PublicAPI/net-android/PublicAPI.Unshipped.txt index 0f242ee73f30..c8621db4917b 100644 --- a/src/Core/maps/src/PublicAPI/net-android/PublicAPI.Unshipped.txt +++ b/src/Core/maps/src/PublicAPI/net-android/PublicAPI.Unshipped.txt @@ -1,12 +1,13 @@ -#nullable enable +#nullable enable +Microsoft.Maui.Maps.IMapElement.Clicked() -> void Microsoft.Maui.Maps.IMapElement.IsVisible.get -> bool Microsoft.Maui.Maps.IMapElement.ZIndex.get -> int -static Microsoft.Maui.Maps.Handlers.MapElementHandler.MapIsVisible(Microsoft.Maui.Maps.Handlers.IMapElementHandler! handler, Microsoft.Maui.Maps.IMapElement! mapElement) -> void -static Microsoft.Maui.Maps.Handlers.MapElementHandler.MapZIndex(Microsoft.Maui.Maps.Handlers.IMapElementHandler! handler, Microsoft.Maui.Maps.IMapElement! mapElement) -> void Microsoft.Maui.Maps.MapSpanTypeConverter Microsoft.Maui.Maps.MapSpanTypeConverter.MapSpanTypeConverter() -> void override Microsoft.Maui.Maps.MapSpanTypeConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool override Microsoft.Maui.Maps.MapSpanTypeConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool override Microsoft.Maui.Maps.MapSpanTypeConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? override Microsoft.Maui.Maps.MapSpanTypeConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? +static Microsoft.Maui.Maps.Handlers.MapElementHandler.MapIsVisible(Microsoft.Maui.Maps.Handlers.IMapElementHandler! handler, Microsoft.Maui.Maps.IMapElement! mapElement) -> void +static Microsoft.Maui.Maps.Handlers.MapElementHandler.MapZIndex(Microsoft.Maui.Maps.Handlers.IMapElementHandler! handler, Microsoft.Maui.Maps.IMapElement! mapElement) -> void diff --git a/src/Core/maps/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt b/src/Core/maps/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt index 0f242ee73f30..c8621db4917b 100644 --- a/src/Core/maps/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt +++ b/src/Core/maps/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt @@ -1,12 +1,13 @@ -#nullable enable +#nullable enable +Microsoft.Maui.Maps.IMapElement.Clicked() -> void Microsoft.Maui.Maps.IMapElement.IsVisible.get -> bool Microsoft.Maui.Maps.IMapElement.ZIndex.get -> int -static Microsoft.Maui.Maps.Handlers.MapElementHandler.MapIsVisible(Microsoft.Maui.Maps.Handlers.IMapElementHandler! handler, Microsoft.Maui.Maps.IMapElement! mapElement) -> void -static Microsoft.Maui.Maps.Handlers.MapElementHandler.MapZIndex(Microsoft.Maui.Maps.Handlers.IMapElementHandler! handler, Microsoft.Maui.Maps.IMapElement! mapElement) -> void Microsoft.Maui.Maps.MapSpanTypeConverter Microsoft.Maui.Maps.MapSpanTypeConverter.MapSpanTypeConverter() -> void override Microsoft.Maui.Maps.MapSpanTypeConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool override Microsoft.Maui.Maps.MapSpanTypeConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool override Microsoft.Maui.Maps.MapSpanTypeConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? override Microsoft.Maui.Maps.MapSpanTypeConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? +static Microsoft.Maui.Maps.Handlers.MapElementHandler.MapIsVisible(Microsoft.Maui.Maps.Handlers.IMapElementHandler! handler, Microsoft.Maui.Maps.IMapElement! mapElement) -> void +static Microsoft.Maui.Maps.Handlers.MapElementHandler.MapZIndex(Microsoft.Maui.Maps.Handlers.IMapElementHandler! handler, Microsoft.Maui.Maps.IMapElement! mapElement) -> void diff --git a/src/Core/maps/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt b/src/Core/maps/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt index 0f242ee73f30..c8621db4917b 100644 --- a/src/Core/maps/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt +++ b/src/Core/maps/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt @@ -1,12 +1,13 @@ -#nullable enable +#nullable enable +Microsoft.Maui.Maps.IMapElement.Clicked() -> void Microsoft.Maui.Maps.IMapElement.IsVisible.get -> bool Microsoft.Maui.Maps.IMapElement.ZIndex.get -> int -static Microsoft.Maui.Maps.Handlers.MapElementHandler.MapIsVisible(Microsoft.Maui.Maps.Handlers.IMapElementHandler! handler, Microsoft.Maui.Maps.IMapElement! mapElement) -> void -static Microsoft.Maui.Maps.Handlers.MapElementHandler.MapZIndex(Microsoft.Maui.Maps.Handlers.IMapElementHandler! handler, Microsoft.Maui.Maps.IMapElement! mapElement) -> void Microsoft.Maui.Maps.MapSpanTypeConverter Microsoft.Maui.Maps.MapSpanTypeConverter.MapSpanTypeConverter() -> void override Microsoft.Maui.Maps.MapSpanTypeConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool override Microsoft.Maui.Maps.MapSpanTypeConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool override Microsoft.Maui.Maps.MapSpanTypeConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? override Microsoft.Maui.Maps.MapSpanTypeConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? +static Microsoft.Maui.Maps.Handlers.MapElementHandler.MapIsVisible(Microsoft.Maui.Maps.Handlers.IMapElementHandler! handler, Microsoft.Maui.Maps.IMapElement! mapElement) -> void +static Microsoft.Maui.Maps.Handlers.MapElementHandler.MapZIndex(Microsoft.Maui.Maps.Handlers.IMapElementHandler! handler, Microsoft.Maui.Maps.IMapElement! mapElement) -> void diff --git a/src/Core/maps/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt b/src/Core/maps/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt index 0f242ee73f30..c8621db4917b 100644 --- a/src/Core/maps/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt +++ b/src/Core/maps/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt @@ -1,12 +1,13 @@ -#nullable enable +#nullable enable +Microsoft.Maui.Maps.IMapElement.Clicked() -> void Microsoft.Maui.Maps.IMapElement.IsVisible.get -> bool Microsoft.Maui.Maps.IMapElement.ZIndex.get -> int -static Microsoft.Maui.Maps.Handlers.MapElementHandler.MapIsVisible(Microsoft.Maui.Maps.Handlers.IMapElementHandler! handler, Microsoft.Maui.Maps.IMapElement! mapElement) -> void -static Microsoft.Maui.Maps.Handlers.MapElementHandler.MapZIndex(Microsoft.Maui.Maps.Handlers.IMapElementHandler! handler, Microsoft.Maui.Maps.IMapElement! mapElement) -> void Microsoft.Maui.Maps.MapSpanTypeConverter Microsoft.Maui.Maps.MapSpanTypeConverter.MapSpanTypeConverter() -> void override Microsoft.Maui.Maps.MapSpanTypeConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool override Microsoft.Maui.Maps.MapSpanTypeConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool override Microsoft.Maui.Maps.MapSpanTypeConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? override Microsoft.Maui.Maps.MapSpanTypeConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? +static Microsoft.Maui.Maps.Handlers.MapElementHandler.MapIsVisible(Microsoft.Maui.Maps.Handlers.IMapElementHandler! handler, Microsoft.Maui.Maps.IMapElement! mapElement) -> void +static Microsoft.Maui.Maps.Handlers.MapElementHandler.MapZIndex(Microsoft.Maui.Maps.Handlers.IMapElementHandler! handler, Microsoft.Maui.Maps.IMapElement! mapElement) -> void diff --git a/src/Core/maps/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt b/src/Core/maps/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt index 0f242ee73f30..c8621db4917b 100644 --- a/src/Core/maps/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt +++ b/src/Core/maps/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt @@ -1,12 +1,13 @@ -#nullable enable +#nullable enable +Microsoft.Maui.Maps.IMapElement.Clicked() -> void Microsoft.Maui.Maps.IMapElement.IsVisible.get -> bool Microsoft.Maui.Maps.IMapElement.ZIndex.get -> int -static Microsoft.Maui.Maps.Handlers.MapElementHandler.MapIsVisible(Microsoft.Maui.Maps.Handlers.IMapElementHandler! handler, Microsoft.Maui.Maps.IMapElement! mapElement) -> void -static Microsoft.Maui.Maps.Handlers.MapElementHandler.MapZIndex(Microsoft.Maui.Maps.Handlers.IMapElementHandler! handler, Microsoft.Maui.Maps.IMapElement! mapElement) -> void Microsoft.Maui.Maps.MapSpanTypeConverter Microsoft.Maui.Maps.MapSpanTypeConverter.MapSpanTypeConverter() -> void override Microsoft.Maui.Maps.MapSpanTypeConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool override Microsoft.Maui.Maps.MapSpanTypeConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool override Microsoft.Maui.Maps.MapSpanTypeConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? override Microsoft.Maui.Maps.MapSpanTypeConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? +static Microsoft.Maui.Maps.Handlers.MapElementHandler.MapIsVisible(Microsoft.Maui.Maps.Handlers.IMapElementHandler! handler, Microsoft.Maui.Maps.IMapElement! mapElement) -> void +static Microsoft.Maui.Maps.Handlers.MapElementHandler.MapZIndex(Microsoft.Maui.Maps.Handlers.IMapElementHandler! handler, Microsoft.Maui.Maps.IMapElement! mapElement) -> void diff --git a/src/Core/maps/src/PublicAPI/net/PublicAPI.Unshipped.txt b/src/Core/maps/src/PublicAPI/net/PublicAPI.Unshipped.txt index 0f242ee73f30..c8621db4917b 100644 --- a/src/Core/maps/src/PublicAPI/net/PublicAPI.Unshipped.txt +++ b/src/Core/maps/src/PublicAPI/net/PublicAPI.Unshipped.txt @@ -1,12 +1,13 @@ -#nullable enable +#nullable enable +Microsoft.Maui.Maps.IMapElement.Clicked() -> void Microsoft.Maui.Maps.IMapElement.IsVisible.get -> bool Microsoft.Maui.Maps.IMapElement.ZIndex.get -> int -static Microsoft.Maui.Maps.Handlers.MapElementHandler.MapIsVisible(Microsoft.Maui.Maps.Handlers.IMapElementHandler! handler, Microsoft.Maui.Maps.IMapElement! mapElement) -> void -static Microsoft.Maui.Maps.Handlers.MapElementHandler.MapZIndex(Microsoft.Maui.Maps.Handlers.IMapElementHandler! handler, Microsoft.Maui.Maps.IMapElement! mapElement) -> void Microsoft.Maui.Maps.MapSpanTypeConverter Microsoft.Maui.Maps.MapSpanTypeConverter.MapSpanTypeConverter() -> void override Microsoft.Maui.Maps.MapSpanTypeConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool override Microsoft.Maui.Maps.MapSpanTypeConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool override Microsoft.Maui.Maps.MapSpanTypeConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? override Microsoft.Maui.Maps.MapSpanTypeConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? +static Microsoft.Maui.Maps.Handlers.MapElementHandler.MapIsVisible(Microsoft.Maui.Maps.Handlers.IMapElementHandler! handler, Microsoft.Maui.Maps.IMapElement! mapElement) -> void +static Microsoft.Maui.Maps.Handlers.MapElementHandler.MapZIndex(Microsoft.Maui.Maps.Handlers.IMapElementHandler! handler, Microsoft.Maui.Maps.IMapElement! mapElement) -> void diff --git a/src/Core/maps/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt b/src/Core/maps/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt index 0f242ee73f30..c8621db4917b 100644 --- a/src/Core/maps/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt +++ b/src/Core/maps/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt @@ -1,12 +1,13 @@ -#nullable enable +#nullable enable +Microsoft.Maui.Maps.IMapElement.Clicked() -> void Microsoft.Maui.Maps.IMapElement.IsVisible.get -> bool Microsoft.Maui.Maps.IMapElement.ZIndex.get -> int -static Microsoft.Maui.Maps.Handlers.MapElementHandler.MapIsVisible(Microsoft.Maui.Maps.Handlers.IMapElementHandler! handler, Microsoft.Maui.Maps.IMapElement! mapElement) -> void -static Microsoft.Maui.Maps.Handlers.MapElementHandler.MapZIndex(Microsoft.Maui.Maps.Handlers.IMapElementHandler! handler, Microsoft.Maui.Maps.IMapElement! mapElement) -> void Microsoft.Maui.Maps.MapSpanTypeConverter Microsoft.Maui.Maps.MapSpanTypeConverter.MapSpanTypeConverter() -> void override Microsoft.Maui.Maps.MapSpanTypeConverter.CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type! sourceType) -> bool override Microsoft.Maui.Maps.MapSpanTypeConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) -> bool override Microsoft.Maui.Maps.MapSpanTypeConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object! value) -> object? override Microsoft.Maui.Maps.MapSpanTypeConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type! destinationType) -> object? +static Microsoft.Maui.Maps.Handlers.MapElementHandler.MapIsVisible(Microsoft.Maui.Maps.Handlers.IMapElementHandler! handler, Microsoft.Maui.Maps.IMapElement! mapElement) -> void +static Microsoft.Maui.Maps.Handlers.MapElementHandler.MapZIndex(Microsoft.Maui.Maps.Handlers.IMapElementHandler! handler, Microsoft.Maui.Maps.IMapElement! mapElement) -> void