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

queryRenderedFeatures is not working on latest Mapbox Standard Map style #13332

Open
RikidWai opened this issue Nov 23, 2024 · 0 comments
Open

Comments

@RikidWai
Copy link

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

import type { MapRef } from 'react-map-gl';
import MAP, { FullscreenControl, GeolocateControl, NavigationControl, Popup, ScaleControl } from 'react-map-gl';

const MapboxMap: React.FC = () => {
  const handleMapClick = (event) => {
    const map = mapRef.current.getMap();
    const features = map.queryRenderedFeatures(event.point);
    console.log('Features:', features); // Returns empty array when clicking on map features
  };
  
  return (
    <Map
      mapStyle="mapbox://styles/mapbox/standard"
      onClick={handleMapClick}
      // ... other props
    >
      {/* map contents */}
    </Map>
);

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

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

1 participant