1.0.0 • Published 4 years ago

react-native-mapbox-direction v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

react-native-mapbox-direction

Getting started

$ npm install react-native-mapbox-direction --save

Or

$ yarn add react-native-mapbox-direction

You need to install react-native-mapbox-gl in your project first!

Props

NameTypeRequiredDescription
mapBoxApiKeystringYesYour Mapbox API key
reffunctionNoMapView Reference
startingPointobjectYesAn object containing departure's latitude and longitude
endingPointobjectYesAn object containing destination's latitude and longitude
colorstringYesDirection's color
onDirectionChangefunctionNoReturn an object with distance and duration

Usage

import { MapView } from 'react-native-mapbox-direction';

    ...

    // Zoom out to display starting point and ending point if in Global mode
    // Follow your current location if in Course mode
    moveCamera = () => {
        this.mapRef.moveCamera(); 
    }

    ...

    render() {

        ...

        <MapView 
            mapBoxApiKey={APIKEY}
            navigationMode="Course" // Or "Global"
            ref={instance => this.mapRef = instance}
            startingPoint={{
                latitude: 48.857908, 
                longitude: 2.302661,
            }}
            endingPoint={{
                latitude: 48.858192, 
                longitude: 2.294981,
            }}
            color="green"
        />

        ...

    }

    ...

}

TODO

  • Display direction on map
  • Change camera modes "Course" or "Global"
  • Add possibility to add an array of points between starting and ending points
  • Remove route parts when moving in realtime

daavidaviid