0

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,

enter image description here

But when I try this line,

import MapView from "react-native-maps";

it gives me this error, please find below screenshot.

enter image description here

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,

  1. https://medium.com/@gurusundesh/getting-started-with-react-native-mapview-5e0bd73aa602
  2. https://codeburst.io/react-native-google-map-with-react-native-maps-572e3d3eee14
  3. https://codedaily.io/tutorials/9/Build-a-Map-with-Custom-Animated-Markers-and-Region-Focus-when-Content-is-Scrolled-in-React-Native
3
  • 1
    Almost all tutorials on react-native-maps are wildly out of date with installation instructions. For example, DO NOT USE react-native link is very clearly stated in the official project's installation docs. Always use the official docs first before following tutorials; especially when using native modules on React Native because of the fast changing environment. Start over and use the official installation instructions first and see if that works. Commented Mar 8, 2018 at 16:34
  • Why downvote? please specify Commented Mar 9, 2018 at 4:35
  • @MichaelCheng see the answer buddy Commented Mar 9, 2018 at 10:36

2 Answers 2

3

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.

enter image description here

Hope this works.

Sign up to request clarification or add additional context in comments.

4 Comments

I'm getting blank map.
What issues you are facing, is there any error? try zoom In/out
I'm getting empty map with only google at bottom of screen
It means map is loading successfully, please set mapview initial region
0

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

2 Comments

make sure u have installed all required dependencies
steps mentioned there only run to problems/issues.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.