Reputation: 6555
Hope it can be silly question but as I'm new in react-native development, don't know how to get rid of this.
I want to put annotations on MapView & it seems this tutorial from react-community is the best way to do it.
I followed the guidelines from this tutorial, created react-native project, it works perfectly.
I run these commands to link react-native-maps,
npm install react-native-maps --save
react-native link
It gives me following output,
But when I try this line,
import MapView from "react-native-maps";
it gives me this error, please find below screenshot.
I tried every thing from top to bottom, clean cache, restarted Metro Bundler every thing but didn't get success yet.
These tutorials I have searched to implement MapView in react-native,
Upvotes: 0
Views: 6939
Reputation: 6555
It has been two days since I'm solving this issue. Finally got the solution.
Thanks to this tutorial.
Solved the issue by changing dependencies in package.json manually: Was:
"dependencies": {
"react": "16.3.0-alpha.1",
"react-native": "0.54.0",
"react-native-maps": "0.20.1"
},
Changed to
"dependencies": {
"react": "16.0.0",
"react-native": "0.51.0",
"react-native-maps": "0.20.1"
},
Then ran npm install
& react-native-git-upgrade
.
My App.js
code is here.
render() {
return (
<View style={styles.container}>
<MapView
provider={PROVIDER_GOOGLE}
style={styles.map}
region={{
latitude: 37.78825,
longitude: -122.4324,
latitudeDelta: 0.015,
longitudeDelta: 0.0121,
}}
></MapView>
</View>
);
}
Finally I got the output like this.
Hope this works.
Upvotes: 3
Reputation: 1374
i guess only link wont work in map you need to follow this instruction too
https://github.com/react-community/react-native-maps/blob/master/docs/installation.md
Upvotes: 0