I am trying to plot polylines that include waypoints on my map in Xamarin forms. Now, I'm sending the following request to the Google Directions API
https://maps.googleapis.com/maps/api/directions/json?mode=driving&transit_routing_preference=less_driving&origin=31 Clairwood Rd, Harare, Zimbabwe&destination=8 Joshua Nkomo St, Bulawayo, Zimbabwe&waypoints=via:No. 1 Railway Ave, R Mugabe Hwy, Kwekwe, Zimbabwe|via:55 Fifth St, Gweru, Zimbabwe|via:Shangani Rd, Harare, Zimbabwe|via:XVJX+62J, Chivhu, Zimbabwe&key=KEY
and I am getting the following response
{
"geocoded_waypoints": [
{
"geocoder_status": "OK",
"place_id": "EiEzMSBDbGFpcndvb2QgUmQsIEhhcmFyZSwgWmltYmFid2UiGhIYChQKEgmBVmGqRqUxGRFK3dLcshV1ExAf",
"types": [
"street_address"
]
},
{
"geocoder_status": "OK",
"partial_match": true,
"place_id": "ChIJIf-owoJpNBkR4od3cGjZYCs",
"types": [
"establishment",
"point_of_interest",
"university"
]
},
{
"geocoder_status": "OK",
"place_id": "ChIJ5TwQo5mUNBkRNhE_iYH5nXU",
"types": [
"street_address"
]
},
{
"geocoder_status": "OK",
"place_id": "EiU4IEpvc2h1YSBOa29tbyBTdCwgQnVsYXdheW8sIFppbWJhYndlIhoSGAoUChIJcXSTo35UtR4RIh0xgqF3-AwQCA",
"types": [
"street_address"
]
}
],
"routes": [],
"status": "ZERO_RESULTS"
}
But, when I send this one
https://maps.googleapis.com/maps/api/directions/json?origin=31 Clairwood Rd, Harare, Zimbabwe&destination=8 Joshua Nkomo St, Bulawayo, Zimbabwe&waypoints=via: Gweru Polytechnic, Gweru|via: M.S.U. Zvishavane Campus, Zvishavane&key=KEY
I get a favourable response.
Now, I'm not sure why I'm getting NO RESULTS response from the first request, could someone assist me as to why. I have researched and researched, I can't seem to find a suitable answer.
I guess I had not optimized my route. The correct way to send the request should be as follows:
https://maps.googleapis.com/maps/api/directions/json?mode=driving&transit_routing_preference=less_driving&origin=31 Clairwood Rd, Harare, Zimbabwe&destination=8 Joshua Nkomo St, Bulawayo, Zimbabwe&waypoints=optimize:true|No. 1 Railway Ave, R Mugabe Hwy, Kwekwe, Zimbabwe|55 Fifth St, Gweru, Zimbabwe|Shangani Rd, Harare, Zimbabwe|XVJX+62J, Chivhu, Zimbabwe&key=KEY
``