Skip to content

[Android] MapElements.Clear() and polygon property changes don't sync to native Google Map #33635

@TimZander

Description

@TimZander

Description

Description

The Microsoft.Maui.Controls.Maps.Map control on Android has two related bugs where changes to MAUI objects are not propagated to the native Google Map:

  1. MapElements.Clear() doesn't remove native polygons - After calling Clear(), the collection count becomes 0, but the polygons remain visible on the native Google Map.

  2. Polygon property changes don't update native polygons - Changing FillColor or StrokeColor (e.g., setting alpha to 0) updates the MAUI object correctly, but the native Google Map polygon is not updated.

Both bugs appear to be in MapElementHandler which is not forwarding changes to the native platform.

Image Image

Steps to Reproduce

BUG 1: Clear() doesn't remove native polygons

  1. Add polygons to Map.MapElements
  2. Call Map.MapElements.Clear()
  3. Observe: MapElements.Count is 0, but polygons are still visible

BUG 2: Property changes don't sync

  1. Add polygons to Map.MapElements
  2. Set polygon.FillColor to a color with alpha = 0
  3. Observe: polygon.FillColor.Alpha is 0.00, but polygon is still visible

Link to public reproduction project repository

https://github.com/TimZander/MauiMapOpacityDemo

Version with bug

9.0.0 GA

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android API 34

Did you find any workaround?

No. Tested workarounds that all failed:

  • Handler?.DisconnectHandler() before Clear()
  • Toggle Map.IsVisible
  • Cycle Map.MapType
  • Move map far away with MoveToRegion()
  • Remove elements one-by-one instead of Clear()
  • Set polygon colors to transparent

Relevant log output

After adding polygons and setting alpha to 0, diagnostics show MAUI state is correct but native isn't updated:

  === DIAGNOSTICS ===
  MapElements.Count: 3
  Map.Handler: MapHandler
  [0] Polygon:
      FillColor: R=1.00 G=0.00 B=0.00 A=0.00   <-- Alpha is 0, but polygon still visible!
      StrokeColor: R=0.55 G=0.00 B=0.00 A=0.00
      Handler: MapElementHandler
  [1] Polygon:
      FillColor: R=0.00 G=1.00 B=0.00 A=0.00
      StrokeColor: R=0.00 G=0.39 B=0.00 A=0.00
      Handler: MapElementHandler

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-controls-mapMap / Mapspartner/syncfusionIssues / PR's with Syncfusion collaborationplatform/androids/triagedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions