react-native-maps-directions show multiple alternative routes

546 Views Asked by At

In the code below Im using react-native-maps to give me the driving distance on a trip from A to B. I can see on the map what route is has chosen for me.

But I would like it to suggest some alternative routes like you know from Google Maps. You know those grey lines you can click on if you prefer to tak another route (usually a few miles longer) than the one suggested.

I have been looking in the react-native-maps-directions documentation for a AlternativeRoutes prop I can turn on, but without any luck.

import MapView, { Marker, PROVIDER_GOOGLE } from "react-native-maps";
import { GooglePlacesAutocomplete } from "react-native-google-places-autocomplete";
import MapViewDirections from "react-native-maps-directions";
 

 <MapView
        ref={mapRef}
        style={styles.map}
        provider={PROVIDER_GOOGLE}
        initialRegion={middleOfDenmark}
      >
        {origin && <Marker coordinate={origin} />}
        {destination && <Marker coordinate={destination} />}
        {origin && destination && (

          <MapViewDirections
            origin={origin}
            destination={destination}
            apikey={googleAPIKey}
            strokeColor="#112D4E"
            strokeWidth={4}
            onReady={calcDistanceOnReady}
          />
        )}
      </MapView>
0

There are 0 best solutions below