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

Return original geometry for GeoJSON features in queryRenderedFeatures #11591

Open
ryanhamley opened this issue Mar 11, 2022 · 1 comment
Open

Comments

@ryanhamley
Copy link
Contributor

Motivation

Consider https://jsfiddle.net/w9bs8jot/. A GeoJSON Line feature is cut into multiple tiles and makes it impossible to query the entire line feature. A customer recently flagged this issue because they wanted users to be able to click on a line feature and get its start and/or end points.

Design Alternatives

There's a potential workaround.

const selectedFeatures = map.queryRenderedFeatures(point);
selectedFeatures.forEach(feature => {
    const source = map.getSource(feature.source);
    // filter for the feature's original coordinates in the source
    console.log('source data: ', source._data.features[0].geometry.coordinates);
})

Design

We could add the original geometry to the features in a GeoJSON vector tile, although this may not be performant enough with large GeoJSON features.

Alternatively, queryRenderedFeatures needs a way to retrieve the original geometry for the feature.

@1ec5
Copy link
Contributor

1ec5 commented Jul 17, 2023

#5639 seems to cover the same thing.

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

No branches or pull requests

2 participants