[Android] ShapeSource onPress handler not working
Open
Nobody has claimed this yet.
bug 🪲
- Dominant language
- Kotlin
- Stars
- 2.9k
- Forks
- 947
- Avg merge
- 6d 37m
- Merged PRs (30d)
- 1
Description
Environment
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".
Steps to reproduce
/**
* 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;
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the supplied React Native App reproduction on Android and inspect the ShapeSource with its onPress handler and FillLayer. Confirm whether pressing the coloured Australia area produces the expected console event; done means the handler reliably logs the press event in the stated environment.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, react-native, typescript
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100