我想使用 road api 来获取我当前位置的距离,并在 onLocationChanged 中添加 Latlng 列表并将一组坐标(大约 100~200 点)捕捉到道路,这将返回一个 json 以获得准确的距离的驾驶。
- 我遇到了路径参数的问题,纬度和经度没有通过这个“|”填充到哪个连接中 但我得到了一个错误。---这是我的网址
protected String getSnapUrl(List<LatLng> pat_value) {
String str_path = null;
for (int x = 0; x < pat_value.size(); x++) {
str_path = "path=" + pat_value.get(x).latitude + "," + pat_value.get(x).longitude + "|";
Log.e("path", "" + pat_value.get(x).latitude + "-" + pat_value.get(x).longitude);
}
String str_interpolate = "interpolate=true";
String key = "key=google key";
String parameters = str_path + "&" + str_interpolate + "&" + key;
String output = "snapToRoads";
String url = output + "?" + parameters;
return url;
}
protected void snapToRoad() {
SnapToRoadAsyncHttpClient.get(getSnapUrl(path), null, new JsonHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
super.onSuccess(statusCode, headers, response);
Log.e("snapToRoad", "" + response);
}
@Override
public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) {
super.onFailure(statusCode, headers, throwable, errorResponse);
Log.e("snapToRoadFail", "" + errorResponse + throwable);
}
@Override
public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) {
super.onFailure(statusCode, headers, responseString, throwable);
Log.e("snapToRoadFail", "" + responseString + throwable);
}
});
}
--错误 snaptoroads 错误:400 消息:路径。