Directions Component For React Native Maps

Category: Others , React Native | December 13, 2017
Author: bramus
Views Total: 844
Official Page: Go to website
Last Update: December 13, 2017
License: MIT

This is a directions component for react-native-maps that allows to draw a route between two coordinates, powered by the Google Maps Directions API.

Installation:

# Yarn
$ yarn add react-native-maps-directions

# NPM
$ npm install react-native-maps-directions --save

Basic usage:

import MapViewDirections from 'react-native-maps-directions';

const origin = {latitude: 37.3318456, longitude: -122.0296002};
const destination = {latitude: 37.771707, longitude: -122.4053769};
const GOOGLE_MAPS_APIKEY = 'YOUR GOOGLE API';

<MapView initialRegion={…}>
  <MapViewDirections
    origin={origin}
    destination={destination}
    apikey={GOOGLE_MAPS_APIKEY}
  />
</MapView>

Preview:

Directions Component For React Native Maps