I have a very simple demo map colouring in Australia. For some reason, the onPress handler on ShapeSource is not working when I press on the coloured area. I am very new to map box so may be missing something? Using the latest RN 0.73.2 on Android, "@rnmapbox/maps": "^10.1.6".
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
*/
import Mapbox from '@rnmapbox/maps';
import React from 'react';
import {Dimensions, StyleSheet, View} from 'react-native';
Mapbox.setAccessToken('');
const {width, height} = Dimensions.get('window');
function App(): React.JSX.Element {
return (
<View style={styles.page}>
<View style={styles.container}>
<Mapbox.MapView
style={styles.map}
scaleBarEnabled={false}
logoEnabled={false}>
<Mapbox.Camera centerCoordinate={[135, -30]} zoomLevel={2.75} />
<Mapbox.ShapeSource
onPress={e => console.log(e)}
id="states"
url="https://raw.githubusercontent.com/rowanhogan/australian-states/master/states.geojson"
/>
<Mapbox.FillLayer id="states-lines" sourceID="states" />
</Mapbox.MapView>
</View>
</View>
);
}
const styles = StyleSheet.create({
page: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
container: {
height,
width,
},
map: {
flex: 1,
},
});
export default App;
I have a very simple demo map colouring in Australia. For some reason, the onPress handler on ShapeSource is not working when I press on the coloured area. I am very new to map box so may be missing something? Using the latest RN 0.73.2 on Android, "@rnmapbox/maps": "^10.1.6".