Skip to content

Add MapElement.IsVisible and MapElement.ZIndex properties#33993

Merged
jfversluis merged 4 commits intonet11.0from
feature/mapelement-visibility-zindex
Feb 25, 2026
Merged

Add MapElement.IsVisible and MapElement.ZIndex properties#33993
jfversluis merged 4 commits intonet11.0from
feature/mapelement-visibility-zindex

Conversation

@jfversluis
Copy link
Copy Markdown
Member

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

Adds IsVisible and ZIndex properties to all map elements (Polygon, Polyline, Circle), enabling visibility toggling and draw-order control without removing elements from the map.

Part of the Maps Control Improvements Epic: #33787 (Phase 4: MapElement Improvements)

Changes

Core Interface (IMapElement)

  • bool IsVisible { get; } — controls element visibility (default: true)
  • int ZIndex { get; } — controls draw order/layering (default: 0)

Controls (MapElement)

  • IsVisibleProperty BindableProperty (bool, default: true)
  • ZIndexProperty BindableProperty (int, default: 0)

Platform Implementations

Android:

  • Polygon.Visible, Polyline.Visible, Circle.Visible for visibility
  • Polygon.ZIndex, Polyline.ZIndex, Circle.ZIndex for draw order
  • Initial values applied after map.Add*() calls; runtime changes via *OnPropertyChanged

iOS/MacCatalyst:

  • Visibility via MKOverlayRenderer.Alpha (0 = hidden, 1 = visible)
  • ZIndex is no-op (MapKit does not support fine-grained overlay ordering)

Tests

  • 5 new unit tests (MapElementIsVisibleDefaultIsTrue, MapElementIsVisibleCanBeSet, MapElementZIndexDefaultIsZero, MapElementZIndexCanBeSet, MapElementIsVisibleWorksOnAllTypes)

Sample

  • MapElementVisibilityGallery with toggle buttons for each element type and ZIndex controls

Verified Working

  • ✅ Android: Toggle Polygon/Polyline/Circle visibility, ZIndex changes (Z=10), Reset
  • ✅ iOS: Toggle Polygon/Polyline/Circle visibility, ZIndex changes, Reset
  • ✅ 34 unit tests pass (including 5 new)

- Add IsVisible (bool, default: true) and ZIndex (int, default: 0) to IMapElement interface
- Add IsVisibleProperty and ZIndexProperty BindableProperties to MapElement
- Android: Apply Visible/ZIndex on native Polygon, Polyline, Circle objects
- iOS/MacCatalyst: Use Alpha 0/1 for visibility; ZIndex is no-op (MapKit limitation)
- Add PropertyMapper entries in MapElementHandler
- Update all 14 PublicAPI.Unshipped.txt files
- Add 5 unit tests for IsVisible and ZIndex
- Add MapElementVisibilityGallery sample page
Copilot AI review requested due to automatic review settings February 11, 2026 13:46
@jfversluis jfversluis added this to the .NET 11.0-preview1 milestone Feb 11, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds IsVisible and ZIndex properties to all map elements (Polygon, Polyline, Circle), enabling visibility toggling and draw-order control without removing elements from the map. This is part of Phase 4 (MapElement Improvements) of the Maps Control Improvements Epic for .NET 11.

Changes:

  • Adds IsVisible (bool, default: true) and ZIndex (int, default: 0) properties to the IMapElement interface and MapElement class
  • Implements platform handlers for Android (full support), iOS/MacCatalyst (visibility via Alpha, ZIndex no-op), Windows/Tizen/Standard (NotImplementedException stubs)
  • Adds 5 unit tests covering default values, setters, and multi-type compatibility
  • Includes sample gallery page demonstrating visibility toggles and ZIndex manipulation

Reviewed changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated no comments.

Show a summary per file
File Description
PublicAPI.Unshipped.txt (all platforms) Adds new public API entries for IMapElement.IsVisible, IMapElement.ZIndex, and MapElementHandler mapper methods
IMapElement.cs Adds IsVisible and ZIndex interface properties with XML documentation
MapElement.cs Implements IsVisible and ZIndex as BindableProperties with getters/setters
MapElementHandler.cs Registers property mappers for IsVisible and ZIndex
MapElementHandler.Android.cs Stub implementations (actual logic in MapHandler.Android.cs)
MapHandler.Android.cs Sets Visible and ZIndex on native Android map elements (Polygon, Polyline, Circle) during creation and updates
MapElementHandler.iOS.cs Implements IsVisible via Alpha (0/1), documents ZIndex no-op due to MapKit limitation
MapElementHandler.Windows/Tizen/Standard.cs NotImplementedException stubs for unsupported platforms
MapTests.cs 5 new unit tests for default values, setters, and cross-element-type compatibility
MapElementVisibilityGallery.cs Sample page with toggle buttons and ZIndex controls
MapsGallery.cs Navigation button to new sample gallery

kubaflo
kubaflo previously approved these changes Feb 23, 2026
Resolve PublicAPI.Unshipped.txt conflicts by keeping both PR and net11.0 API entries.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jfversluis and others added 2 commits February 24, 2026 14:07
- Add missing using directives (Microsoft.Maui.Controls, Microsoft.Maui.Graphics)
  that caused CS0246 errors on the net11.0 (non-platform) TFM
- Remove non-existent Assign() extension method call, use local variable instead
- Remove duplicate PublicAPI.Unshipped.txt entries for static readonly fields
  (was causing RS0017 warnings)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
PinItemsSourceGallery.xaml.cs defines a local Location class in the same
namespace that shadows Microsoft.Maui.Devices.Sensors.Location. Use a
type alias (GeoLocation) to disambiguate and add missing Microsoft.Maui
using for GridLength, TextAlignment, and Thickness.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jfversluis jfversluis merged commit 7499d82 into net11.0 Feb 25, 2026
22 of 27 checks passed
@jfversluis jfversluis deleted the feature/mapelement-visibility-zindex branch February 25, 2026 12:44
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.
@github-actions github-actions bot locked and limited conversation to collaborators Mar 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants