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

Add getClusterExpansionZoom to ShapeSource #1279

Merged
merged 1 commit into from
Mar 19, 2021

Conversation

janicduplessis
Copy link
Contributor

@janicduplessis janicduplessis commented Mar 15, 2021

This allows using the mapbox sdk to get the zoom needed to expand a cluster by adding getClusterExpansionZoom to instances of ShapeSource.

The code is mostly adapted from a similar method features on ShapeSource.

Tested these changes in an app on iOS and android.

const source = React.useRef(null);

...

<MapboxGL.ShapeSource
  ref={source}
  onPress={async (e) => {
    const feature = e.features[0];
    if (feature.properties?.cluster) {
      const zoom = await source.current.getClusterExpansionZoom(
        feature.properties.cluster_id,
      );
      // use zoom
    }
  }}
  cluster
  clusterMaxZoomLevel={13}
  clusterRadius={40}
/>

@ferdicus
Copy link
Member

Thanks @janicduplessis 🙇🏿

@ferdicus ferdicus merged commit ce1cf78 into rnmapbox:master Mar 19, 2021
@janicduplessis janicduplessis deleted the cluster-zoom branch March 19, 2021 17:04
@LukeLaScala
Copy link

LukeLaScala commented May 13, 2021

This seems to be broken on the latest build. I'm getting source.current.getClusterExpansionZoom is not a function using the code provided above. Is there somewhere else to report this bug?

@ferdicus
Copy link
Member

This seems to be broken on the latest build. I'm getting source.current.getClusterExpansionZoom is not a function using the code provided above. Is there somewhere else to report this bug?

@LukeLaScala, feel free to open an issue ticket, but please follow the guidelines

Thanks 🙇🏿

@natedx
Copy link

natedx commented May 15, 2021

I am going to open one, it is broken for me too!

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.

5 participants