我正试图在Xamarin形式的地图上绘制包含路点的折线。现在,我正在向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
,我得到以下响应
{
"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"
}
但是,当我发送这个
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
我得到了一个很好的回应。
现在,我不知道为什么我从第一个请求得到没有结果的响应,有人可以帮助我为什么。我研究了又研究,似乎找不到一个合适的答案。
我想我没有优化我的路线。发送请求的正确方法应该如下所示:
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
``