-
Hello! I'm trying to query layers that are included with the styleURL. Basic example: export default function MapScreen() {
const map = useRef<MapView>(null);
return (
<View style={styles.page}>
<View style={styles.container}>
<MapView
ref={map}
style={styles.map}
styleURL={"mapbox://styles/..../....."}
onPress={async (e) => {
const position =
e.geometry.type === "Point"
? e.geometry.coordinates
: [-106.452487, 47.962584];
console.log(position);
const res = await map.current?.queryRenderedFeaturesAtPoint(
position
);
console.log(res);
}}
></MapView>
</View>
</View>
);
} I would assume this would log features in the layers, but nothing:
Am I understanding this API wrong or is there another way layers should be queried? Thanks! |
Beta Was this translation helpful? Give feedback.
Answered by
ajzbc
Oct 11, 2024
Replies: 1 comment
-
Ahh! The query is expecting the screen coordinates... onPress={async ({ properties }) => {
if (!properties) {
return;
}
const res = await map.current?.queryRenderedFeaturesAtPoint([
properties.screenPointX,
properties.screenPointY,
]);
console.log(res);
}} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
ajzbc
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ahh!
The query is expecting the screen coordinates...