【发布时间】:2016-05-31 23:29:59
【问题描述】:
大家好,你能帮我如何绘制折线吗 现在我有我从 googlemap 得到的 json 我的问题是如何使用这个 json 绘制折线
{
"snappedPoints": [
{
"location": {
"latitude": 14.554309626417714,
"longitude": 121.01901383856206
},
"originalIndex": 0,
"placeId": "ChIJ62cMsw_JlzMRCXM5jZU83BM"
},
{
"location": {
"latitude": 14.554430199999995,
"longitude": 121.01905140000001
},
"placeId": "ChIJ62cMsw_JlzMRCXM5jZU83BM"
},
{
"location": {
"latitude": 14.5544967,
"longitude": 121.01907999999997
},
"placeId": "ChIJ62cMsw_JlzMRCXM5jZU83BM"
},
{
"location": {
"latitude": 14.554658699999997,
"longitude": 121.01916489999999
},
"placeId": "ChIJ62cMsw_JlzMRCXM5jZU83BM"
},
{
"location": {
"latitude": 14.55596745847264,
"longitude": 121.02005815511896
},
"originalIndex": 1,
"placeId": "ChIJ62cMsw_JlzMRCXM5jZU83BM"
}
]
}
我已经把它转成字符串了,
RequestQueue requestQueue = Volley.newRequestQueue(this);
String url = String.format("https://roads.googleapis.com/v1/snapToRoads?path=" + EncodingSnap + "&interpolate=true&key=AIzaSyBNixSdb4ofwpeXzZ7_MXoKnrps352Ji7U");
JsonObjectRequest jsObjRequest = new JsonObjectRequest
(Request.Method.GET, url, null, new com.android.volley.Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
SnapToRoadInfo scheduleRequest = new Gson().fromJson(response.toString(), SnapToRoadInfo.class);
}
}, new com.android.volley.Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
// TODO Auto-generated method stub
Log.e("Error", error.toString());
}
});
requestQueue.add(jsObjRequest);
我使用 Volley 序列化代码并将其发送到谷歌地图 api,然后,现在我有结果,现在如何解码?
【问题讨论】:
标签: java google-maps android-studio