Repository navigation
[Maps] Support custom icons for cluster markers #36336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kubaflo
merged 31 commits into
dotnet:net11.0
from
kevin68:feature/maps-custom-cluster-appearance
Jul 30, 2026
+1,467
−77
Merged
Changes from 25 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
90f3630
[Maps] Add ClusterInfo context type
29c317c
[Maps] Add Map.ClusterImageProvider and ClusterImageSource
4af3f93
[Maps] Add IMap.GetClusterImage resolving provider then static icon
7900f15
[Maps] Restore trailing newline in Core.maps PublicAPI files
0eb7e7e
[Android] Render custom cluster image when provided
9a02b82
[iOS] Render custom cluster image when provided
882fbc9
[Maps] Demonstrate custom cluster icons in ClusteringGallery sample
b3ea13a
[Maps/iOS] Always call GetClusterImage even when MemberAnnotations is…
547f375
[Android] Fix indentation lost during rebase conflict resolution
c126870
[Maps] Rebuild clusters when ClusterImageSource/Provider changes
93c8d03
[Maps] Add test for GetClusterImage with an empty pin list
1435b7e
[sample] Split ClusteringGallery button row to avoid overflow
9b09ca0
[sample] Reset cluster-icon demo state in OnAddCustomPinsClicked
22480cd
[Maps] Add DIM to GetClusterImage, fix iOS cluster count, cache clust…
21ba3b9
[iOS] Fix MKClusterAnnotation type detection for preview.5 binding skew
a304310
[Maps] Make IMap.GetClusterImage a required interface member
9643a15
[Maps] Fix cluster-icon cache keys and add iOS load-failure fallback
f5d340a
[Maps] Harden cluster-icon paths: crash guards, perf, and cache lifec…
03d771c
[Maps] Simplify cluster-marker null check with null-conditional indexer
4d6d6a3
[Maps] Resolve cluster pins lazily so count-only providers pay nothing
e51015d
[iOS] Map: Extract cluster detection into TryGetClusterAnnotation helper
67a607b
[iOS] Map: Detect binding-skew clusters in selection path, keep LazyM…
32557ad
[Maps] Honor UriImageSource.CacheValidity in cluster icon caches
7025e47
[iOS] Map: Make LazyMapPinList.Count consistent with its indexer
69552be
[Maps] Evict cluster icon cache oldest-first instead of wiping it
a2ae5f0
Merge net11.0 into feature/maps-custom-cluster-appearance
Copilot e896c38
Fix cluster image lifecycle and caching
Copilot 4ce9d92
Merge remote-tracking branch 'origin/net11.0' into feature/maps-custo…
Copilot 731cb7f
Merge remote-tracking branch 'origin/net11.0' into feature/maps-custo…
Copilot 9e7de19
Merge origin/net11.0 into feature/maps-custom-cluster-appearance
Copilot 5962eab
Merge origin/net11.0 into feature/maps-custom-cluster-appearance
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using Microsoft.Maui.Devices.Sensors; | ||
|
|
||
| namespace Microsoft.Maui.Controls.Maps | ||
| { | ||
| /// <summary> | ||
| /// Describes a pin cluster, passed to an image provider callback so the | ||
| /// application can produce a custom icon for the cluster marker. | ||
| /// </summary> | ||
| public sealed class ClusterInfo | ||
| { | ||
| IReadOnlyList<Pin>? _pins; | ||
| readonly Func<IReadOnlyList<Pin>>? _pinsFactory; | ||
| string? _clusteringIdentifier; | ||
| readonly Func<string>? _clusteringIdentifierFactory; | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="ClusterInfo"/> class. | ||
| /// </summary> | ||
| /// <param name="count">The number of pins in the cluster.</param> | ||
| /// <param name="clusteringIdentifier">The clustering identifier shared by the cluster's pins.</param> | ||
| /// <param name="pins">The pins contained in the cluster.</param> | ||
| /// <param name="location">The geographic location (centroid) of the cluster.</param> | ||
| public ClusterInfo(int count, string clusteringIdentifier, IReadOnlyList<Pin> pins, Location location) | ||
| { | ||
| Count = count; | ||
| _clusteringIdentifier = clusteringIdentifier ?? throw new ArgumentNullException(nameof(clusteringIdentifier)); | ||
| _pins = pins ?? throw new ArgumentNullException(nameof(pins)); | ||
| Location = location ?? throw new ArgumentNullException(nameof(location)); | ||
| } | ||
|
|
||
| // Lazy path used by the handler: defers the O(members × pins) resolution until the provider | ||
| // actually reads Pins/ClusteringIdentifier, so a count-only provider pays nothing. | ||
| internal ClusterInfo(int count, Location location, Func<IReadOnlyList<Pin>> pinsFactory, Func<string> clusteringIdentifierFactory) | ||
| { | ||
| Count = count; | ||
| Location = location; | ||
| _pinsFactory = pinsFactory; | ||
| _clusteringIdentifierFactory = clusteringIdentifierFactory; | ||
| } | ||
|
|
||
| /// <summary>Gets the number of pins contained in the cluster.</summary> | ||
| /// <remarks>This is the authoritative member count, independent of how many entries <see cref="Pins"/> holds.</remarks> | ||
| public int Count { get; } | ||
|
|
||
| /// <summary>Gets the clustering identifier shared by the pins in this cluster.</summary> | ||
| /// <remarks>Falls back to <see cref="Pin.DefaultClusteringIdentifier"/> when no member pin could be resolved.</remarks> | ||
| public string ClusteringIdentifier => _clusteringIdentifier ??= _clusteringIdentifierFactory!(); | ||
|
|
||
| /// <summary>Gets the pins contained in this cluster.</summary> | ||
| /// <remarks> | ||
| /// On some platforms (iOS) not every cluster member can be resolved back to a <see cref="Pin"/>, | ||
| /// so this list can contain fewer than <see cref="Count"/> entries - use <see cref="Count"/> for badge numbers. | ||
| /// </remarks> | ||
| public IReadOnlyList<Pin> Pins => _pins ??= _pinsFactory!(); | ||
|
|
||
| /// <summary>Gets the geographic location (centroid) of the cluster.</summary> | ||
| public Location Location { get; } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.