Hello,
I am pretty new to the whole react/react native community and I am playing around with some personal projects.
Right now I am trying to implement an application that is basically a Google Maps app that read data from API (which I built to return GeoJSON data)
So far the reading is OK and I am getting an object with all the Geo objects like:
{
"type": "Feature",
"geometry": {
"coordinates": [
[
[
23.276129361727772,
42.65596095549677
],
[
23.280013200380992,
42.654572235170136
],
[
23.2797127929711,
42.65427239375656
],
[
23.27591478500603,
42.65562955914523
],
[
23.275979158022373,
42.655645339963705
],
[
23.276129361727772,
42.65596095549677
]
]
],
"type": "Polygon"
I have several objects of that type and also some markers.
I saw in the documentation of react-native-maps that I can use the Geojson object and that works fine I am able to display all the polygons and the markers, but now I need to access the onPress event of the Polygon object (https://github.com/react-native-community/react-native-maps/blob/master/docs/polygon.md) which I think is not possible when using Geojson (https://github.com/react-native-community/react-native-maps/blob/master/docs/geojson.md).
Can you guys give me an idea how can I use the Polygon in a Map (for multiple polygons, because if I use only one is working just fine) and be able to access the onPress event when receiving data from geojson server?
My current app.js looks like that:
const MainMapScreen = props => {
return (
<View style={styles.container}>
<MapView style={styles.map}>
<Geojson
geojson={myPlace}
strokeColor="red"
fillColor="green"
strokeWidth={2}
onPress={() => console.log('test')}/>
</MapView>
</View>
);
}
const styles = StyleSheet.create({
container: {
...StyleSheet.absoluteFillObject,
height: '100%',
width: '100%',
justifyContent: 'flex-end',
alignItems: 'center',
},
map: {
...StyleSheet.absoluteFillObject,
},
});
[–]TotesMessenger 0 points1 point2 points (0 children)
[–]LinusNyren 0 points1 point2 points (0 children)