MapView
While you won't be using it in this project, the MapView is a good example of a common element that you'll use in a lot of other projects, and is worth taking some time with.
At its most basic implementation, a MapView will render an interactive map in a defined area.
Map features like markers and callouts are achievable through the use of an annotations parameter:
However, it's worth noting that the native MapView shipping in React Native is an iOS-only implementation, and will fail for Android builds. The official recommendation to work around this is to use a react-native-maps by Leland Richardson. You can add it to your project with npm install react-native-maps --save
and then using rnpm
to link the native components with rnpm link
. Usage roughly mirrors the standard MapView component:
You can set region as a part of your state:
However, implementations of advanced features like markers are different from the default MapView, with react-native-maps
choosing to opt for a nested component format:
Last updated