【问题标题】:How to request in roads api using snap to roads?如何使用捕捉到道路的道路 API 请求?
【发布时间】:2016-04-23 05:27:44
【问题描述】:

我想使用 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);
        }
    });

}

--Error snaptoroads error:400 message:path.

【问题讨论】:

    标签: java android android-async-http google-roads-api


    【解决方案1】:

    状态码 400 是由于请求无效。Roads API 最多接受 100 分,请尝试减少您的积分。

    【讨论】:

      猜你喜欢
      • 2018-05-04
      • 2020-10-26
      • 1970-01-01
      • 2014-04-25
      • 2018-10-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多