I am trying to render directions polyline on map using coordinates from MapQuest REST API but I get the polyline not showing on top of road exatctly. Rather its showing a different output. I want to draw the polyline on top of the road exactly. I am sending the following request to get the directions (using MapQuest Directions Route API):
Then depending on the above request session id, I am sending another request to get the coordinates (using MapQuest Directions Route Shape API):
I am using the array route.shape.shapePoints
, How I am I supposed to get polyline correctly plotted above roads on map?
Code I am using:
<MapView
style={{ flex: 1 }}
showsUserLocation
initialRegion={{
latitude,
longitude,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421
}}
>
<MapView.Polyline strokeWidth={2} strokeColor="red" coordinates={this.state.coords}></MapView.Polyline>
</MapView>
Below is a screenshot of current map I am getting:
Try setting the generalize option to something low like 0 or 10.