Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/Controls/Maps/src/Circle.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using Microsoft.Maui.Devices.Sensors;
using Microsoft.Maui.Graphics;
using Microsoft.Maui.Maps;
Expand Down Expand Up @@ -56,5 +57,16 @@ public Color FillColor
get => (Color)GetValue(FillColorProperty);
set => SetValue(FillColorProperty, value);
}

/// <summary>
/// Occurs when the user clicks/taps on the circle element
/// </summary>
public event EventHandler? CircleClicked;

void IMapElement.Clicked()
{
CircleClicked?.Invoke(this, EventArgs.Empty);
}

}
}
2 changes: 2 additions & 0 deletions src/Controls/Maps/src/HandlerImpl/MapElement.Impl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
12 changes: 12 additions & 0 deletions src/Controls/Maps/src/Polygon.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down Expand Up @@ -31,6 +33,16 @@ public Color FillColor
/// </summary>
public IList<Location> Geopath { get; }

/// <summary>
/// Occurs when the user clicks/taps on the polygon element
/// </summary>
public event EventHandler? PolygonClicked;

void IMapElement.Clicked()
{
PolygonClicked?.Invoke(this, EventArgs.Empty);
}

/// <summary>
/// Initializes a new instance of the <see cref="Polygon"/> class.
/// </summary>
Expand Down
12 changes: 12 additions & 0 deletions src/Controls/Maps/src/Polyline.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -14,6 +16,16 @@ public partial class Polyline : MapElement
/// </summary>
public IList<Location> Geopath { get; }

/// <summary>
/// Occurs when the user clicks/taps on the polyline element
/// </summary>
public event EventHandler? PolylineClicked;

void IMapElement.Clicked()
{
PolylineClicked?.Invoke(this, EventArgs.Empty);
}

/// <summary>
/// Initializes a new instance of the <see cref="Polyline"/> class.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -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
11 changes: 7 additions & 4 deletions src/Controls/Maps/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
11 changes: 7 additions & 4 deletions src/Controls/Maps/src/PublicAPI/net/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.Pages.MapsGalleries.MapElementClickGallery"
xmlns:maps="http://schemas.microsoft.com/dotnet/2021/maui/maps"
xmlns:sensors="clr-namespace:Microsoft.Maui.Devices.Sensors;assembly=Microsoft.Maui.Essentials"
Title="MapElement Click Events">
<Grid RowDefinitions="Auto,*">
<Label x:Name="StatusLabel"
Text="Tap on a circle, polygon, or polyline"
Padding="10"
FontSize="16"
HorizontalTextAlignment="Center" />
<maps:Map x:Name="map" Grid.Row="1">
<x:Arguments>
<maps:MapSpan>
<x:Arguments>
<sensors:Location>
<x:Arguments>
<x:Double>37.79752</x:Double>
<x:Double>-122.40183</x:Double>
</x:Arguments>
</sensors:Location>
<x:Double>0.02</x:Double>
<x:Double>0.02</x:Double>
</x:Arguments>
</maps:MapSpan>
</x:Arguments>
</maps:Map>
</Grid>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}
};
Expand Down
Loading
Loading