为什么我无法从我的路线 api 请求中获得概览折线
Why can't I get an overview polyline from my directions api request
我正在尝试以 Xamarin 形式在我的地图上绘制包含 waypoints 的多段线。现在,我向 Google 方向 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
``
我正在尝试以 Xamarin 形式在我的地图上绘制包含 waypoints 的多段线。现在,我向 Google 方向 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
``