The function encodeURIComponent was messing up the final url due to which the map was returning an invalid response. Removing the encodeURI component function call fixed it for me.
Test Case:
handleGetDirections = () => {
const data = {
source: {
latitude:Number(24.9158528),
longitude:Number(67.1313890)
},
destination: {
latitude: Number(24.9158528),
longitude: Number(67.1313892)
},
params: [
{
key: "travelmode",
value: "driving" // may be "walking", "bicycling" or "transit" as well
},
{
key: "dir_action",
value: "navigate" // this instantly initializes navigation using the given travel mode
}
],
waypoints: [
{
latitude: Number(-33.8600026),
longitude: Number(18.697453)
},
{
latitude: Number(-33.8600036),
longitude: Number(18.697493)
}
]
}
getDirections(data)
}
The function encodeURIComponent was messing up the final url due to which the map was returning an invalid response. Removing the encodeURI component function call fixed it for me.
Test Case: