diff --git a/src/Controls/Maps/src/MapElement.cs b/src/Controls/Maps/src/MapElement.cs
index 6d469f7de041..31d15554ff10 100644
--- a/src/Controls/Maps/src/MapElement.cs
+++ b/src/Controls/Maps/src/MapElement.cs
@@ -26,6 +26,20 @@ public partial class MapElement : Element
typeof(MapElement),
5f);
+ /// Bindable property for .
+ public static readonly BindableProperty IsVisibleProperty = BindableProperty.Create(
+ nameof(IsVisible),
+ typeof(bool),
+ typeof(MapElement),
+ true);
+
+ /// Bindable property for .
+ public static readonly BindableProperty ZIndexProperty = BindableProperty.Create(
+ nameof(ZIndex),
+ typeof(int),
+ typeof(MapElement),
+ 0);
+
///
/// Gets or sets the stroke color. This is a bindable property.
///
@@ -45,6 +59,28 @@ public float StrokeWidth
set => SetValue(StrokeWidthProperty, value);
}
+ ///
+ /// Gets or sets a value indicating whether the map element is visible on the map.
+ /// The default value is .
+ /// This is a bindable property.
+ ///
+ public bool IsVisible
+ {
+ get => (bool)GetValue(IsVisibleProperty);
+ set => SetValue(IsVisibleProperty, value);
+ }
+
+ ///
+ /// Gets or sets the z-index of the map element, which controls its draw order relative to other elements.
+ /// Higher values are drawn on top of lower values. The default value is 0.
+ /// This is a bindable property.
+ ///
+ public int ZIndex
+ {
+ get => (int)GetValue(ZIndexProperty);
+ set => SetValue(ZIndexProperty, value);
+ }
+
///
/// Gets or sets the platform counterpart of this map element.
///
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 31029602ec64..90a0ef71d1ea 100644
--- a/src/Controls/Maps/src/PublicAPI/net-android/PublicAPI.Unshipped.txt
+++ b/src/Controls/Maps/src/PublicAPI/net-android/PublicAPI.Unshipped.txt
@@ -1,4 +1,11 @@
#nullable enable
+
+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
+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 31029602ec64..90a0ef71d1ea 100644
--- a/src/Controls/Maps/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt
+++ b/src/Controls/Maps/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt
@@ -1,4 +1,11 @@
#nullable enable
+
+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
+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 31029602ec64..90a0ef71d1ea 100644
--- a/src/Controls/Maps/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt
+++ b/src/Controls/Maps/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt
@@ -1,4 +1,11 @@
#nullable enable
+
+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
+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 31029602ec64..90a0ef71d1ea 100644
--- a/src/Controls/Maps/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt
+++ b/src/Controls/Maps/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt
@@ -1,4 +1,11 @@
#nullable enable
+
+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
+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 31029602ec64..90a0ef71d1ea 100644
--- a/src/Controls/Maps/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt
+++ b/src/Controls/Maps/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt
@@ -1,4 +1,11 @@
#nullable enable
+
+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
+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 31029602ec64..90a0ef71d1ea 100644
--- a/src/Controls/Maps/src/PublicAPI/net/PublicAPI.Unshipped.txt
+++ b/src/Controls/Maps/src/PublicAPI/net/PublicAPI.Unshipped.txt
@@ -1,4 +1,11 @@
#nullable enable
+
+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
+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 31029602ec64..90a0ef71d1ea 100644
--- a/src/Controls/Maps/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt
+++ b/src/Controls/Maps/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt
@@ -1,4 +1,11 @@
#nullable enable
+
+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
+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/MapElementVisibilityGallery.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/MapElementVisibilityGallery.cs
new file mode 100644
index 000000000000..33d4bdb8d03b
--- /dev/null
+++ b/src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/MapElementVisibilityGallery.cs
@@ -0,0 +1,149 @@
+using Microsoft.Maui;
+using Microsoft.Maui.Controls;
+using Microsoft.Maui.Controls.Maps;
+using Microsoft.Maui.Graphics;
+using Microsoft.Maui.Maps;
+using GeoLocation = Microsoft.Maui.Devices.Sensors.Location;
+
+namespace Maui.Controls.Sample.Pages.MapsGalleries
+{
+ public class MapElementVisibilityGallery : ContentPage
+ {
+ readonly Polygon _polygon;
+ readonly Polyline _polyline;
+ readonly Circle _circle;
+ readonly Label _statusLabel;
+
+ public MapElementVisibilityGallery()
+ {
+ Title = "Element Visibility & ZIndex";
+
+ var center = new GeoLocation(47.6062, -122.3321); // Seattle
+
+ _polygon = new Polygon
+ {
+ StrokeColor = Colors.Blue,
+ StrokeWidth = 3,
+ FillColor = Color.FromRgba(0, 0, 255, 64),
+ ZIndex = 1,
+ };
+ _polygon.Geopath.Add(new GeoLocation(47.615, -122.345));
+ _polygon.Geopath.Add(new GeoLocation(47.615, -122.320));
+ _polygon.Geopath.Add(new GeoLocation(47.600, -122.320));
+ _polygon.Geopath.Add(new GeoLocation(47.600, -122.345));
+
+ _polyline = new Polyline
+ {
+ StrokeColor = Colors.Red,
+ StrokeWidth = 5,
+ ZIndex = 2,
+ };
+ _polyline.Geopath.Add(new GeoLocation(47.610, -122.350));
+ _polyline.Geopath.Add(new GeoLocation(47.610, -122.315));
+
+ _circle = new Circle
+ {
+ Center = center,
+ Radius = new Distance(500),
+ StrokeColor = Colors.Green,
+ StrokeWidth = 3,
+ FillColor = Color.FromRgba(0, 255, 0, 64),
+ ZIndex = 3,
+ };
+
+ var map = new Microsoft.Maui.Controls.Maps.Map(new MapSpan(center, 0.03, 0.03));
+ map.MapElements.Add(_polygon);
+ map.MapElements.Add(_polyline);
+ map.MapElements.Add(_circle);
+
+ _statusLabel = new Label
+ {
+ Text = "All elements visible. ZIndex: Polygon=1, Polyline=2, Circle=3",
+ HorizontalTextAlignment = TextAlignment.Center,
+ AutomationId = "StatusLabel"
+ };
+
+ var togglePolygonBtn = new Button { Text = "Toggle Polygon", AutomationId = "TogglePolygon" };
+ togglePolygonBtn.Clicked += (s, e) =>
+ {
+ _polygon.IsVisible = !_polygon.IsVisible;
+ UpdateStatus();
+ };
+
+ var togglePolylineBtn = new Button { Text = "Toggle Polyline", AutomationId = "TogglePolyline" };
+ togglePolylineBtn.Clicked += (s, e) =>
+ {
+ _polyline.IsVisible = !_polyline.IsVisible;
+ UpdateStatus();
+ };
+
+ var toggleCircleBtn = new Button { Text = "Toggle Circle", AutomationId = "ToggleCircle" };
+ toggleCircleBtn.Clicked += (s, e) =>
+ {
+ _circle.IsVisible = !_circle.IsVisible;
+ UpdateStatus();
+ };
+
+ var bringPolygonTopBtn = new Button { Text = "Polygon to Top (Z=10)", AutomationId = "PolygonTop" };
+ bringPolygonTopBtn.Clicked += (s, e) =>
+ {
+ _polygon.ZIndex = 10;
+ UpdateStatus();
+ };
+
+ var resetZIndexBtn = new Button { Text = "Reset ZIndex", AutomationId = "ResetZIndex" };
+ resetZIndexBtn.Clicked += (s, e) =>
+ {
+ _polygon.ZIndex = 1;
+ _polyline.ZIndex = 2;
+ _circle.ZIndex = 3;
+ UpdateStatus();
+ };
+
+ var controls = new VerticalStackLayout
+ {
+ Spacing = 4,
+ Padding = new Thickness(8),
+ Children =
+ {
+ _statusLabel,
+ new HorizontalStackLayout
+ {
+ Spacing = 4,
+ HorizontalOptions = LayoutOptions.Center,
+ Children = { togglePolygonBtn, togglePolylineBtn, toggleCircleBtn }
+ },
+ new HorizontalStackLayout
+ {
+ Spacing = 4,
+ HorizontalOptions = LayoutOptions.Center,
+ Children = { bringPolygonTopBtn, resetZIndexBtn }
+ }
+ }
+ };
+
+ Content = new Grid
+ {
+ RowDefinitions =
+ {
+ new RowDefinition(GridLength.Star),
+ new RowDefinition(GridLength.Auto),
+ },
+ Children =
+ {
+ map,
+ controls
+ }
+ };
+
+ Grid.SetRow(controls, 1);
+ }
+
+ void UpdateStatus()
+ {
+ _statusLabel.Text = $"Polygon:{(_polygon.IsVisible ? "ON" : "OFF")}(Z={_polygon.ZIndex}) " +
+ $"Polyline:{(_polyline.IsVisible ? "ON" : "OFF")}(Z={_polyline.ZIndex}) " +
+ $"Circle:{(_circle.IsVisible ? "ON" : "OFF")}(Z={_circle.ZIndex})";
+ }
+ }
+}
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 ee6bfdf593e1..594a21829caa 100644
--- a/src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/MapsGallery.cs
+++ b/src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/MapsGallery.cs
@@ -19,6 +19,7 @@ public MapsGallery()
GalleryBuilder.NavButton("Pins ItemsSource", () => new PinItemsSourceGallery(), Navigation),
GalleryBuilder.NavButton("Circle", () => new CircleGallery(), Navigation),
GalleryBuilder.NavButton("Polygon", () => new PolygonsGallery(), Navigation),
+ GalleryBuilder.NavButton("Element Visibility & ZIndex", () => new MapElementVisibilityGallery(), Navigation),
}
}
};
diff --git a/src/Controls/tests/Core.UnitTests/MapTests.cs b/src/Controls/tests/Core.UnitTests/MapTests.cs
index f938498d57ea..566eef8fc451 100644
--- a/src/Controls/tests/Core.UnitTests/MapTests.cs
+++ b/src/Controls/tests/Core.UnitTests/MapTests.cs
@@ -410,6 +410,57 @@ public void WorksWithNullItems()
Assert.True(IsMapWithItemsSource(itemsSource, map));
}
+ [Fact]
+ public void MapElementIsVisibleDefaultIsTrue()
+ {
+ var polygon = new Polygon();
+ Assert.True(polygon.IsVisible);
+ }
+
+ [Fact]
+ public void MapElementIsVisibleCanBeSet()
+ {
+ var polygon = new Polygon();
+ polygon.IsVisible = false;
+ Assert.False(polygon.IsVisible);
+ }
+
+ [Fact]
+ public void MapElementZIndexDefaultIsZero()
+ {
+ var polyline = new Polyline();
+ Assert.Equal(0, polyline.ZIndex);
+ }
+
+ [Fact]
+ public void MapElementZIndexCanBeSet()
+ {
+ var circle = new Circle
+ {
+ Center = new Location(0, 0),
+ Radius = new Distance(100)
+ };
+ circle.ZIndex = 5;
+ Assert.Equal(5, circle.ZIndex);
+ }
+
+ [Fact]
+ public void MapElementIsVisibleWorksOnAllTypes()
+ {
+ var polygon = new Polygon { IsVisible = false };
+ var polyline = new Polyline { IsVisible = false };
+ var circle = new Circle
+ {
+ Center = new Location(0, 0),
+ Radius = new Distance(100),
+ IsVisible = false
+ };
+
+ Assert.False(polygon.IsVisible);
+ Assert.False(polyline.IsVisible);
+ Assert.False(circle.IsVisible);
+ }
+
// Checks if for every item in the items source there's a corresponding pin
static bool IsMapWithItemsSource(IEnumerable itemsSource, Map map)
{
diff --git a/src/Core/maps/src/Core/IMapElement.cs b/src/Core/maps/src/Core/IMapElement.cs
index 410212180df5..c9815403af4f 100644
--- a/src/Core/maps/src/Core/IMapElement.cs
+++ b/src/Core/maps/src/Core/IMapElement.cs
@@ -9,5 +9,16 @@ public interface IMapElement : IElement, IStroke
/// Gets or sets the platform counterpart of this map element.
///
object? MapElementId { get; set; }
+
+ ///
+ /// Gets a value indicating whether the map element is visible on the map.
+ ///
+ bool IsVisible { get; }
+
+ ///
+ /// Gets the z-index of the map element, which controls its draw order relative to other elements.
+ /// Higher values are drawn on top of lower values.
+ ///
+ int ZIndex { get; }
}
}
diff --git a/src/Core/maps/src/Handlers/Map/MapHandler.Android.cs b/src/Core/maps/src/Handlers/Map/MapHandler.Android.cs
index 3efed6f29e67..b34fcbfd6dfd 100644
--- a/src/Core/maps/src/Handlers/Map/MapHandler.Android.cs
+++ b/src/Core/maps/src/Handlers/Map/MapHandler.Android.cs
@@ -154,6 +154,12 @@ void PolygonOnPropertyChanged(IGeoPathMapElement mauiPolygon)
nativePolygon.StrokeWidth = (float)mauiPolygon.StrokeThickness;
nativePolygon.Points = mauiPolygon.Select(position => new LatLng(position.Latitude, position.Longitude)).ToList();
+
+ if (mauiPolygon is IMapElement mapElement)
+ {
+ nativePolygon.Visible = mapElement.IsVisible;
+ nativePolygon.ZIndex = mapElement.ZIndex;
+ }
}
void PolylineOnPropertyChanged(IGeoPathMapElement mauiPolyline)
@@ -168,6 +174,12 @@ void PolylineOnPropertyChanged(IGeoPathMapElement mauiPolyline)
nativePolyline.Width = (float)mauiPolyline.StrokeThickness;
nativePolyline.Points = mauiPolyline.Select(position => new LatLng(position.Latitude, position.Longitude)).ToList();
+
+ if (mauiPolyline is IMapElement mapElement)
+ {
+ nativePolyline.Visible = mapElement.IsVisible;
+ nativePolyline.ZIndex = mapElement.ZIndex;
+ }
}
@@ -189,6 +201,11 @@ void CircleOnPropertyChanged(ICircleMapElement mauiCircle)
nativeCircle.Radius = mauiCircle.Radius.Meters;
nativeCircle.StrokeWidth = (float)mauiCircle.StrokeThickness;
+ if (mauiCircle is IMapElement mapElement)
+ {
+ nativeCircle.Visible = mapElement.IsVisible;
+ nativeCircle.ZIndex = mapElement.ZIndex;
+ }
}
protected APolyline? GetNativePolyline(IGeoPathMapElement polyline)
@@ -530,6 +547,12 @@ void AddPolyline(IGeoPathMapElement polyline)
polyline.MapElementId = nativePolyline.Id;
+ if (polyline is IMapElement mapElement)
+ {
+ nativePolyline.Visible = mapElement.IsVisible;
+ nativePolyline.ZIndex = mapElement.ZIndex;
+ }
+
_polylines.Add(nativePolyline);
}
}
@@ -552,6 +575,12 @@ void AddPolygon(IGeoPathMapElement polygon)
polygon.MapElementId = nativePolygon.Id;
+ if (polygon is IMapElement mapElement)
+ {
+ nativePolygon.Visible = mapElement.IsVisible;
+ nativePolygon.ZIndex = mapElement.ZIndex;
+ }
+
_polygons.Add(nativePolygon);
}
@@ -573,6 +602,12 @@ void AddCircle(ICircleMapElement circle)
circle.MapElementId = nativeCircle.Id;
+ if (circle is IMapElement mapElement)
+ {
+ nativeCircle.Visible = mapElement.IsVisible;
+ nativeCircle.ZIndex = mapElement.ZIndex;
+ }
+
_circles.Add(nativeCircle);
}
}
diff --git a/src/Core/maps/src/Handlers/MapElement/MapElementHandler.Android.cs b/src/Core/maps/src/Handlers/MapElement/MapElementHandler.Android.cs
index f715a2fdf58c..5bc4c33b3577 100644
--- a/src/Core/maps/src/Handlers/MapElement/MapElementHandler.Android.cs
+++ b/src/Core/maps/src/Handlers/MapElement/MapElementHandler.Android.cs
@@ -117,5 +117,19 @@ public static void MapCenter(IMapElementHandler handler, IMapElement mapElement)
circleOptions.InvokeCenter(new LatLng(circleMapElement.Center.Latitude, circleMapElement.Center.Longitude));
}
+
+ public static void MapIsVisible(IMapElementHandler handler, IMapElement mapElement)
+ {
+ // Visibility is applied on the native object after it is added to the map,
+ // via the UpdateMapElement path in MapHandler.Android.cs.
+ // PolygonOptions/PolylineOptions/CircleOptions don't expose a Visible setter.
+ }
+
+ public static void MapZIndex(IMapElementHandler handler, IMapElement mapElement)
+ {
+ // ZIndex is applied on the native object after it is added to the map,
+ // via the UpdateMapElement path in MapHandler.Android.cs.
+ // PolygonOptions/PolylineOptions/CircleOptions don't expose a ZIndex setter.
+ }
}
}
diff --git a/src/Core/maps/src/Handlers/MapElement/MapElementHandler.Standard.cs b/src/Core/maps/src/Handlers/MapElement/MapElementHandler.Standard.cs
index 234a9f4ca869..b55446d6e93c 100644
--- a/src/Core/maps/src/Handlers/MapElement/MapElementHandler.Standard.cs
+++ b/src/Core/maps/src/Handlers/MapElement/MapElementHandler.Standard.cs
@@ -7,5 +7,7 @@ public partial class MapElementHandler : ElementHandler
public static void MapStroke(IMapElementHandler handler, IMapElement mapElement) => throw new System.NotImplementedException();
public static void MapStrokeThickness(IMapElementHandler handler, IMapElement mapElement) => throw new System.NotImplementedException();
public static void MapFill(IMapElementHandler handler, IMapElement mapElement) => throw new System.NotImplementedException();
+ public static void MapIsVisible(IMapElementHandler handler, IMapElement mapElement) => throw new System.NotImplementedException();
+ public static void MapZIndex(IMapElementHandler handler, IMapElement mapElement) => throw new System.NotImplementedException();
}
}
diff --git a/src/Core/maps/src/Handlers/MapElement/MapElementHandler.Tizen.cs b/src/Core/maps/src/Handlers/MapElement/MapElementHandler.Tizen.cs
index 234a9f4ca869..b55446d6e93c 100644
--- a/src/Core/maps/src/Handlers/MapElement/MapElementHandler.Tizen.cs
+++ b/src/Core/maps/src/Handlers/MapElement/MapElementHandler.Tizen.cs
@@ -7,5 +7,7 @@ public partial class MapElementHandler : ElementHandler
public static void MapStroke(IMapElementHandler handler, IMapElement mapElement) => throw new System.NotImplementedException();
public static void MapStrokeThickness(IMapElementHandler handler, IMapElement mapElement) => throw new System.NotImplementedException();
public static void MapFill(IMapElementHandler handler, IMapElement mapElement) => throw new System.NotImplementedException();
+ public static void MapIsVisible(IMapElementHandler handler, IMapElement mapElement) => throw new System.NotImplementedException();
+ public static void MapZIndex(IMapElementHandler handler, IMapElement mapElement) => throw new System.NotImplementedException();
}
}
diff --git a/src/Core/maps/src/Handlers/MapElement/MapElementHandler.Windows.cs b/src/Core/maps/src/Handlers/MapElement/MapElementHandler.Windows.cs
index eaf8d85e3e59..6cb6cff20db7 100644
--- a/src/Core/maps/src/Handlers/MapElement/MapElementHandler.Windows.cs
+++ b/src/Core/maps/src/Handlers/MapElement/MapElementHandler.Windows.cs
@@ -8,5 +8,7 @@ public partial class MapElementHandler : ElementHandler
public static void MapStroke(IMapElementHandler handler, IMapElement mapElement) => throw new System.NotImplementedException();
public static void MapStrokeThickness(IMapElementHandler handler, IMapElement mapElement) => throw new System.NotImplementedException();
public static void MapFill(IMapElementHandler handler, IMapElement mapElement) => throw new System.NotImplementedException();
+ public static void MapIsVisible(IMapElementHandler handler, IMapElement mapElement) => throw new System.NotImplementedException();
+ public static void MapZIndex(IMapElementHandler handler, IMapElement mapElement) => throw new System.NotImplementedException();
}
}
diff --git a/src/Core/maps/src/Handlers/MapElement/MapElementHandler.cs b/src/Core/maps/src/Handlers/MapElement/MapElementHandler.cs
index 74bc219cca5b..c8cb453477f8 100644
--- a/src/Core/maps/src/Handlers/MapElement/MapElementHandler.cs
+++ b/src/Core/maps/src/Handlers/MapElement/MapElementHandler.cs
@@ -26,6 +26,8 @@ public partial class MapElementHandler : IMapElementHandler
[nameof(IMapElement.Stroke)] = MapStroke,
[nameof(IMapElement.StrokeThickness)] = MapStrokeThickness,
[nameof(IFilledMapElement.Fill)] = MapFill,
+ [nameof(IMapElement.IsVisible)] = MapIsVisible,
+ [nameof(IMapElement.ZIndex)] = MapZIndex,
#if MONOANDROID
["Geopath"] = MapGeopath,
[nameof(ICircleMapElement.Radius)] = MapRadius,
diff --git a/src/Core/maps/src/Handlers/MapElement/MapElementHandler.iOS.cs b/src/Core/maps/src/Handlers/MapElement/MapElementHandler.iOS.cs
index ddec558fce9e..0d6ebed492bd 100644
--- a/src/Core/maps/src/Handlers/MapElement/MapElementHandler.iOS.cs
+++ b/src/Core/maps/src/Handlers/MapElement/MapElementHandler.iOS.cs
@@ -59,5 +59,17 @@ public static void MapFill(IMapElementHandler handler, IMapElement mapElement)
if (handler.PlatformView is MKCircleRenderer circleRenderer)
circleRenderer.FillColor = platformColor;
}
+
+ public static void MapIsVisible(IMapElementHandler handler, IMapElement mapElement)
+ {
+ handler.PlatformView.Alpha = mapElement.IsVisible ? 1 : 0;
+ }
+
+ public static void MapZIndex(IMapElementHandler handler, IMapElement mapElement)
+ {
+ // MapKit does not support fine-grained ZIndex on overlays.
+ // Overlays are drawn in the order they are added to the map.
+ // The property is accepted but has no visual effect on iOS/MacCatalyst.
+ }
}
}
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 9bd77ba275b9..0f242ee73f30 100644
--- a/src/Core/maps/src/PublicAPI/net-android/PublicAPI.Unshipped.txt
+++ b/src/Core/maps/src/PublicAPI/net-android/PublicAPI.Unshipped.txt
@@ -1,4 +1,9 @@
#nullable enable
+
+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
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 9bd77ba275b9..0f242ee73f30 100644
--- a/src/Core/maps/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt
+++ b/src/Core/maps/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt
@@ -1,4 +1,9 @@
#nullable enable
+
+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
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 9bd77ba275b9..0f242ee73f30 100644
--- a/src/Core/maps/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt
+++ b/src/Core/maps/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt
@@ -1,4 +1,9 @@
#nullable enable
+
+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
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 9bd77ba275b9..0f242ee73f30 100644
--- a/src/Core/maps/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt
+++ b/src/Core/maps/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt
@@ -1,4 +1,9 @@
#nullable enable
+
+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
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 9bd77ba275b9..0f242ee73f30 100644
--- a/src/Core/maps/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt
+++ b/src/Core/maps/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt
@@ -1,4 +1,9 @@
#nullable enable
+
+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
diff --git a/src/Core/maps/src/PublicAPI/net/PublicAPI.Unshipped.txt b/src/Core/maps/src/PublicAPI/net/PublicAPI.Unshipped.txt
index 9bd77ba275b9..0f242ee73f30 100644
--- a/src/Core/maps/src/PublicAPI/net/PublicAPI.Unshipped.txt
+++ b/src/Core/maps/src/PublicAPI/net/PublicAPI.Unshipped.txt
@@ -1,4 +1,9 @@
#nullable enable
+
+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
diff --git a/src/Core/maps/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt b/src/Core/maps/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt
index 9bd77ba275b9..0f242ee73f30 100644
--- a/src/Core/maps/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt
+++ b/src/Core/maps/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt
@@ -1,4 +1,9 @@
#nullable enable
+
+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