Update ShapeSource methods to make it usable with any cluster - #1499
Conversation
…ShapeSource source data
|
@tr3v3r Thanks for the PR 👍 looks nice. One issue could be backward compatibility. What do you think?! |
|
@mfazekas thanks for quick response! |
|
@mfazekas Also, I think we can add a comment/warning that cluster_id arg. is deprecated and will be removed in version 9+. What do you think? |
|
@mfazekas PR updated. Instead of adding some if / else statement inside native methods to detect the type of an argument I've just copied prev. methods implementation to reduce the number of possible bugs and make easier the process of removing this functionality in the future. If we merge this I also provide PR that deletes deprecated functionality for release 9+. Thanks for your time ) |
…om === -1, add check if mSorce exists on Android
|
thanks 🙇🏿 |
…ox#1499) * Update ShapeSource methods to make it usable with any cluster within ShapeSource source data * Get back possibility to pass cluster_id as argument for backward compatibility * Add more description into changelog, get rid of redundant check of zoom === -1, add check if mSorce exists on Android * Fix description text
…ox#1499) * Update ShapeSource methods to make it usable with any cluster within ShapeSource source data * Get back possibility to pass cluster_id as argument for backward compatibility * Add more description into changelog, get rid of redundant check of zoom === -1, add check if mSorce exists on Android * Fix description text
Description
Since current implementation of
getClusterExpansionZoom,getClusterLeavesandgetClusterChildrenuses querySourceFeatures / featuresMatchingPredicate to get desired data, it sets a limitation on functionality provided by native (original) corresponding methods. For now, obtaining needed data from this method is only possible for the clusters that are currently rendered on the map. But according to docs of the SDK it should be possible to use it on any cluster ( even deeply nested )This PR updates these methods by passing the cluster itself not cluster_id.
Checklist
yarn generateCHANGELOG.mdindex.d.ts)/example)Screenshot OR Video
Possible use case:
To zoom or just find a cluster for any single point on the map.
Solution:
Recursively use
getClusterChildren(rootCluster)to find desired cluster and then withgetClusterExpansionZoom(deeplyNestedCluster)smoothly zoom to it. ( For example, user searches some place on the map using search input )Example