I am starting to "learn" React Native and the first tutorial I see uses a <MapView />
component. I have tried different ways to show a map but I am not able to.
According to the video itself, it imports MapView
from expo
. But after reading some documentation at the Expo site I changed the import to react-native-maps
. The error changes but there is no map at all.
When importing MapView
from expo
I get an Invariant Violation error. But when importing it from react-native-maps
I get a blank screen on Android and iOS simulators.
I found this online real-time editor with their own iOS / Android / Web simulators. This is the example: https://snack.expo.io/B1H3VWtDH
This is the code. It has two lines...
import React from 'react';import { Text, View } from 'react-native';import MapView from 'react-native-maps';function App() { const [region, setRegion] = React.useState({ latitude: -30.8501718, longitude: -50.1700368, latitudeDelta: 0.922, longitudeDelta: 0.0421 }) return (<View><Text>Map screen</Text><MapView initialRegion={region} style={{ flex: 1 }} /></View> );}export default App;
What is wrong? Any comments will be appreciated.