
- React Native Tutorial
- React Native - Home
- Core Concepts
- React Native - Overview
- React Native - Environment Setup
- React Native - App
- React Native - State
- React Native - Props
- React Native - Styling
- React Native - Flexbox
- React Native - ListView
- React Native - Text Input
- React Native - ScrollView
- React Native - Images
- React Native - HTTP
- React Native - Buttons
- React Native - Animations
- React Native - Debugging
- React Native - Router
- React Native - Running IOS
- React Native - Running Android
- Components and APIs
- React Native - View
- React Native - WebView
- React Native - Modal
- React Native - ActivityIndicator
- React Native - Picker
- React Native - Status Bar
- React Native - Switch
- React Native - Text
- React Native - Alert
- React Native - Geolocation
- React Native - AsyncStorage
- React Native Useful Resources
- React Native - Quick Guide
- React Native - Useful Resources
- React Native - Discussion
React Native - MapView
In this chapter we will show you how to use maps in React Native.
Create File
Let's create src/components/home/MapViewExample.js
Using Maps
We are adding several props to MapView.
showsUserLocation and followUserLocation are booleans. You will need users permission before it can be used.
We also want to enable zoom by setting zoomEnabled = {true}
src/components/home/MapViewExample.js
Example
import React, { Component } from 'react' import { MapView, StyleSheet } from 'react-native' export default MapViewExample = (props) => { return ( <MapView style = {styles.map} showsUserLocation = {false} followUserLocation = {false} zoomEnabled = {true} /> ) } const styles = StyleSheet.create ({ map: { height: 400, marginTop: 80 } })
And finally we need to pass this to HomeContainer component.
src/components/home/HomeContainer.js
Example
import React, { Component } from 'react' import { MapView } from 'react-native' import MapViewExample from './MapViewExample' export default class HomeContainer extends Component { constructor() { super(); } render() { return ( <MapViewExample/> ); } }
When we run the app, we can see the map.
Output

Advertisements