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

ShapeShource#onPress e.nativeEvent is now deprecated, use e.features #700

Merged
merged 1 commit into from
Mar 6, 2020

Conversation

mfazekas
Copy link
Contributor

@mfazekas mfazekas commented Mar 1, 2020

Currently in ShapeSource/VectorSource onPress returns a single feature, we also cannot get location of press.

onPress(e) {
    const feature = e.nativeEvent.payload;
    ...
}

With the new version the above works, but deprecated, and you can now access all the features that were at the point of click via: features (the old payload only contained the first feature) There is also additional coordinates and point describing the location of the press

onPress({features, coordinates, point}) {
    ...
}

Fixes: #611

@mfazekas
Copy link
Contributor Author

mfazekas commented Mar 6, 2020

@kristfal @mattijsf any feedback on this change?! Is it fine to do it in 8.0?!

@mfazekas mfazekas force-pushed the shapesource-onpress-nativeevent branch from 8987a2f to ce59722 Compare March 6, 2020 08:54
@mfazekas mfazekas marked this pull request as ready for review March 6, 2020 09:12
@mfazekas mfazekas changed the title [WIP] ShapeShource#onPress e.nativeEvent is now deprecated, use e.features ShapeShource#onPress e.nativeEvent is now deprecated, use e.features Mar 6, 2020
@mfazekas mfazekas force-pushed the shapesource-onpress-nativeevent branch from ce59722 to 8022a1c Compare March 6, 2020 09:14
@mfazekas mfazekas force-pushed the shapesource-onpress-nativeevent branch from 8022a1c to 00a1250 Compare March 6, 2020 09:23
@mfazekas mfazekas merged commit 11874cd into rnmapbox:master Mar 6, 2020
@tanguy64
Copy link

Thanks @mfazekas for improving this function !
I tried it with ShapeSource - does the goal of the features arg is to get all the leaves of a clustered point when pressed ?
I successfully have the feature properties of a single point. But when I press a clustered point I cannot retrieve the different leaves of it. I still have the same as before eq. the properties with point_count and cluster=true...

@mfazekas
Copy link
Contributor Author

mfazekas commented Mar 11, 2020

@tanguy64 the features does contains multiple features in case you don't have clustering enabled but you have multiple features at the place of click.

We could allow ways to return cluster details - for childrenOfCluster

@tanguy64
Copy link

Ok that's very clear thank you. Indeed I have clustering enabled. And childrenOfCluster or leavesOfCluster are exactly what I am looking for zooming to the bounds of a clustered point children onPress and getting the children data.

@bboure
Copy link
Contributor

bboure commented Apr 8, 2020

@mfazekas I think typing is broken here after this change
https://github.com/react-native-mapbox-gl/maps/blob/master/index.d.ts#L707

@mfazekas
Copy link
Contributor Author

mfazekas commented Apr 8, 2020

@bboure pls submit a PR, typing is lagging behind the library, sorry

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.

ShapeSource.onPress unable to return multiple features
3 participants