Skip to content

Accessing child properties data from a cluster #2124

Answered by mattbbc
mattbbc asked this question in Q&A
Discussion options

You must be logged in to vote

I've answered my own question - in the onClick handler you can get a reference to the map, retrieve the source data and query using getClusterLeaves():

if (mapRef.current) {
    const map = mapRef.current.getMap();

    const selectedFeatures = e.features[0];

    const src = map.getSource('my-data');

    src.getClusterLeaves(selectedFeatures.properties.cluster_id, selectedFeatures.properties.cluster_id, 0, (err, features) => {
      if (err) console.log(err);
      console.log('features from cluster', features);
    });
  }

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by mattbbc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant