Google 地图方向 Api Return 方向错误?

Google Maps Direction Api Return wrong directions?

我从方向 API 得到了两点之间的响应并对其进行了解析并在地图上绘制折线,但问题是线被绘制在建筑物上

绘制折线的代码:

 JSONArray steps = response.getJSONObject(0).getJSONArray("legs").getJSONObject(0).getJSONArray("steps");
                    PolylineOptions rectOptions = new PolylineOptions();
                    for (int i = 0; i < steps.length(); i++) {


                        //add start_location
                        JSONObject stepS = steps.getJSONObject(i).getJSONObject("start_location");
                        rectOptions.add(new LatLng(stepS.getDouble("lat"), stepS.getDouble("lng")));

                        //add end location
                        JSONObject stepE = steps.getJSONObject(i).getJSONObject("end_location");
                        rectOptions.add(new LatLng(stepE.getDouble("lat"), stepE.getDouble("lng")));

编辑: 我找到了解决方案

rectOptions.addAll(PolyUtil.decode(steps.getJSONObject(i).getJSONObject("polyline").getString("points")));

解决方案 : 添加这一行解决了问题

rectOptions.addAll(PolyUtil.decode(steps.getJSONObject(i).getJSONObject("polyline").getString("points")));