Skip to content

Commit

Permalink
Use shadow transform for queryRenderedFeatures call (visgl#2280)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pessimistress authored Sep 12, 2023
1 parent 2c0312e commit 45c3615
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/mapbox/create-ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ export default function createRef<
const result = map.queryTerrainElevation(lnglat, options);
map.transform = tr;
return result;
},
queryRenderedFeatures: (geometry?: any, options?: any) => {
const tr = map.transform;
map.transform = mapInstance.transform;
const result = map.queryRenderedFeatures(geometry, options);
map.transform = tr;
return result;
}
};

Expand Down
4 changes: 4 additions & 0 deletions src/mapbox/mapbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -583,14 +583,18 @@ export default class Mapbox<

private _queryRenderedFeatures(point: Point) {
const map = this._map;
const tr = map.transform;
const {interactiveLayerIds = []} = this.props;
try {
map.transform = this._renderTransform;
return map.queryRenderedFeatures(point, {
layers: interactiveLayerIds.filter(map.getLayer.bind(map))
});
} catch {
// May fail if style is not loaded
return [];
} finally {
map.transform = tr;
}
}

Expand Down

0 comments on commit 45c3615

Please sign in to comment.