-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
queryRenderedFeatures is not working on latest Mapbox Standard Map style #13332
Comments
the latest release notes show these changes which are looking promising:
Looking through the source, there is some documentation for this method /**
* Add an interaction — a named gesture handler of a given type.
* *This API is experimental and subject to change in future versions*.
*
* @experimental
* @param {string} id The ID of the interaction.
* @param {Object} interaction The interaction object with the following properties.
* @param {string} interaction.type The type of gesture to handle (e.g. 'click').
* @param {Object} [interaction.filter] Filter expression to narrow down the interaction to a subset of features under the pointer.
* @param {TargetDescriptor} [interaction.featureset] The featureset descriptor to narrow down features to.
* Either `{layerId: string}` to reference features in the root style layer, or `{featuresetId: string, importId?: string}` to reference features in an imported style.
* @param {Function} interaction.handler A handler function that will be invoked on the gesture and receive a `{feature, interaction}` object as a parameter.
* @returns {Map} Returns itself to allow for method chaining.
*
* @example
* map.addInteraction('poi-click', {
* type: 'click',
* handler(e) {
* console.log(e.feature);
* }
* });
*/
addInteraction(id: string, interaction: Interaction) {
this._interactions.add(id, interaction);
return this;
} Unfortunately I gave it a quick attempt and it was not working, the feature value is just mapbox-gl-js/debug/featuresets.html Line 4 in 596da6b
|
The reason why it's not working at the moment is because the Standard style doesn't expose interactable elements yet — they need to be defined at the style level to be available for querying. It will become available when the next version of the Standard style is released (hopefully soon). |
mapbox-gl-js version: ^3.8.0
browser: Any browser
Steps to Trigger Behavior
Create a new map instance using the Mapbox Standard style
Add click handler that uses queryRenderedFeatures()
Click on various map features (buildings, roads, POIs)
Check console output or handler results
Link to Demonstration
React Example
Expected Behavior
Clicking on map features (buildings, roads, POIs) should return an array of features with their properties
Should work similarly to how it works with 'streets-v12' style
Actual Behavior
queryRenderedFeatures() returns an empty array when clicking on map features
No features are detected even when clicking on visible map elements
The text was updated successfully, but these errors were encountered: