Skip to content
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

Expand Clusters on Tap #38

Merged
merged 2 commits into from
Jun 12, 2024
Merged

Conversation

hactar
Copy link
Collaborator

@hactar hactar commented May 15, 2024

This PR adds an expandClustersOnTapping viewModifier. When used, if a user taps a cluster feature, the expand function of its source is used to choose a new zoom level.

I chose a slightly different implementation than discussed. Instead of taking a toggle bool, it takes an array of ClusterLayer which describes which layers/sources are the cluster layers. The reason is that the visibleFeatures function does not return which layer or source was tapped, so if we do not require users to provide which layers and sources to check, our implementation would instead need to go through all sources and layers of the map until it finds where this tapped cluster feature originated from. By making users provide us with the potential layers/sources, this makes the process more efficient and allows for filtering if required.

@ianthetechie
Copy link
Collaborator

Same as the other PR; code looks good and I'll merge after some quick sanity testing in our apps :)

})
.expandClustersOnTapping(clusteredLayers: [ClusterLayer(
layerIdentifier: "simple-circles-clusters",
sourceIdentifier: "points"
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be be nice if we can find a way to pass in a source DSL type directly rather than just strings at some point. A string definitely has to be an option though (you may not control all layers of interest via the DSL), so this isn't a blocker.

@ianthetechie ianthetechie merged commit 50673f0 into maplibre:main Jun 12, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants