Reputation: 1
I’m new to React Native, but what I’m trying to do is port over my react app that centers around maps. Usually in react I can load Geojson files directly to data layer of Google Maps, but how do I go about doing this in react-native-maps? Also anytime the Geojson is loaded in react I can attach an event listener to trigger something when you click on that area, how is that accomplished in RN. (React code below)
I've tried working with (Polygon) but the format with the coordinates in Geojson doesn't play well with each other.
map.data.addGeoJson(localGeoJsonFile.json);
map.data.addListener(‘click’, function(event) {
getInfo = event.feature.getProperty(‘city_name’);
});
Upvotes: 0
Views: 6967
Reputation: 11
First of all, have a look at https://github.com/frankrowe/react-native-geojson, it allows you to load GeoJSON data into a MapView element from react-native-maps. Concerning click events, although the element supports onPress property, currently react-native-geojson doesn't propagate such properties to the calculated Polygon from GeoJSON.
A first attempt to support onPress on every feature is made in this fork https://github.com/Appcademy/react-native-geojson
Upvotes: 1