Skip to content

Add getClusterExpansionZoom to ShapeSource - #1279

Merged
ferdicus merged 1 commit into
rnmapbox:masterfrom
janicduplessis:cluster-zoom
Mar 19, 2021
Merged

Add getClusterExpansionZoom to ShapeSource#1279
ferdicus merged 1 commit into
rnmapbox:masterfrom
janicduplessis:cluster-zoom

Conversation

@janicduplessis

@janicduplessis janicduplessis commented Mar 15, 2021

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

LukeLaScala commented May 13, 2021

Copy link
Copy Markdown

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
Copy Markdown
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

natedx commented May 15, 2021

Copy link
Copy Markdown

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