如何在Mapbox Android中获取路线的原始Json数据



我如何在android MapboxDocsLink 中获得如此链接所示的原始数据

我想使用这些数据来获得每小时的坐标点,直到目的地

对于Android,请参阅https://docs.mapbox.com/android/java/examples/show-directions-on-a-map

onResponse()内部:https://github.com/mapbox/mapbox-android-demo/blob/master/MapboxAndroidDemo/src/main/java/com/mapbox/mapboxandroiddemo/examples/javaservices/DirectionsActivity.java#L156

这将打印出响应的json:Log.d("DirectionsActivity", "response.body().toJson(); = " + response.body().toJson());

Android Studio的logcat有一个最大字符限制,这就是为什么整个路由JSON可能不在logcat中(就像下面的JSON片段中一样(。https://gist.github.com/kiirpi/7747423就是如何打印出完整的东西。在此要旨中,将sb替换为response.body().toJson()

2020-08-13 13:50:30.189 3157-3157/com.mapbox.mapboxandroiddemo.debug D/DirectionsActivity:"response.body().toJson(); ="{
"code":"Ok",
"waypoints":[
{
"name":"Calle Real de la Alhambra",
"location":[
-3.588224,
37.175903
]
},
{
"name":"Calle Ancha de Capuchinos",
"location":[
-3.601397,
37.184341
]
}
],
"routes":[
{
"routeIndex":"0",
"distance":4226.283,
"duration":1420.659,
"geometry":"}d`|eA~f_zEmEnTcAbEiRjt@pL`OrFoT`CuFl@AjABrAs@xCcGfIyNvHeLvHoHvDgBN`DOpB}DjGwIlNeEpJ{FpMyG|Om@dCTzAd@r@zAIbAo@rAuAjBwEdE}IpGgJhHiIlJaGdEoAbGz@il@d_BcAvE}@vE{Ebl@aH`t@sFjj@e@fCyBbU}@dT?jG?xCbB|Sd@xF]zKaD`OeO~ZcAvBmFpKqG|RgD_I]q@u@UmOq\qBwEqCcEgCoAwDiAyQi\uJkUmE_R{AaGiBgJkGaZsAaG]}@qC_IsAmD{EwMsAiIcAuRsAyKeAoMe@oLcAkWm@wNkAyOW{BmEaVcFwWwCoO_EsRqBgSsAqU{@oCm@cCm@_@m@I_NdCsB^gXhGy\tFcLpBkKpAqH|As@R}@LcARm@ZmE\qGh@cGp@sFzCqBxBiMhJ_EtGoChG}@lFyBbMiBbN}@nMqBfSUbEG`FOrIgCpTcB~F{@pAxGrIyBbN?nC}@pK]vN]zJm@vHmEfZqCpUMhGOxNTnBVr@bKvb@N`ONtYvCnUpHpi@j@zH?|IeEz\s@vFsArKe@|J_@xTe@zJ]rIaCfd@sApBiBhA{AzCe@hEOdCdA|TLrAt@xBWf@M\?t@?z@{ARcFr@aIp@_^dDkcA~IkBRqB\_Df@cAr@kLRkA?uJ}@ca@yByFRcL`@wb@aADrANjFvXpbAbGjPrFjOtIfUbL`WnS{QvNsLtT{QpWsU",
"weight":1946.376,
"weight_name":"routability",
"legs":[
{
"distance":4226.283,
"duration":1420.659,
"summary":"Paseo de los Coches, Calle Carrera del Darro",
"steps":[
{
"distance":124.957,
"duration":23.992,
"geometry":"}d`|eA~f_zEmEnTcAbEiRjt@",
"name":"Calle Real de la Alhambra",
"mode":"driving",
"maneuver":{
"location":[
-3.588224,
37.175903
],
"bearing_before":0.0,
"bearing_after":290.0,
"instruction":"Head west on Calle Real de la Alhambra",
"type":"depart"
},
"driving_side":"right",
"weight":26.053,
"intersections":[
{
"location":[
-3.588224,
37.175903
],
"bearings":[
290
],
"entry":[
true
],
"out":0
},
{
"location":[
-3.588665,
37.176041
],
"bearings":[
1,
113,
294
],
"entry":[
false,
false,
true
],
"in":1,
"out":2
}
]
},
{
"distance":33.0,
"duration":24.94,
"geometry":"y`a|eA~wazEpL`O",
"name":"",
"mode":"driving",
"maneuver":{
"location":[
-3.589519,
37.17635
],
"bearing_before":294.0,
"bearing_after":223.0,
"instruction":"Turn left",
"type":"turn",
"modifier":"left"
},
"driving_side":"right",
"weight":30.534,
"intersections":[
{
"location":[
-3.589519,
37.17635
],
"bearings":[
114,
223,
280
],
"entry":[
false,
true,
true
],
"in":0,
"out":1
}
]
},
{
"distance":160.0,
"duration":86.02,
"geometry":"gs`|eA`hbzErFoT`CuFl@AjABrAs@xCcGfIyNvHeLvHoHvDgB",
"name":"",
"mode":"driving",
"maneuver":{
"location":[
-3.589777,
37.176132
],
"bearing_before":223.0,
"bearing_after":113.0,
"instruction":"Turn left",
"type":"turn",
"modifier":"left"
},
"driving_side":"right",
"weight":91.422,
"intersections":[
{
"location":[
-3.589777,
37.176132
],
"bearings":[
43,
113,
291
],
"entry":[
false,
true,
true
],
"in":0,
"out":1
},
{
"location":[
-3.589309,
37.175922
],
"bearings":[
183,
312
],
"classes":[
"tunnel"
],
"entry":[
true,
false
],
"in":1,
"out":0
},
{
"location":[
-3.589311,
37.175884
],
"bearings":[
3,
136
],
"entry":[
false,
true
],
"in":0,
"out":1
}
]
},
{
"distance":145.0,
"duration":61.0,
"geometry":"yx~{eAlw_zEN`DOpB}DjGwIlNeEpJ{FpMyG|Om@dCTzAd@r@",
"name":"Paseo del Generalife",
"mode":"driving",
"maneuver":{
"location":[
-3.588487,
37.175198
],
"bearing_before":152.0,
"bearing_after":277.0,
"instruction":"Turn right onto Paseo del Generalife",
"type":"turn",
"modifier":"right"
},
"driving_side":"right",
"weight":71.8,
"intersections":[
{
"location":[
-3.588487,
37.175198
],
"bearings":[
144,
184,
277,
332
],
"entry":[
false,
false,
true,
false
],
"in":3,
"out":2
}
]
},
{
"distance":140.0,
"duration":68.25,
"geometry":"}_`|eArkbzEzAIbAo@rAuAjBwEdE}IpGgJhHiIlJaGdEoAbGz@",
"name":"Paseo del Generalife",
"mode":"driving",
"maneuver":{
"location":[
-3.589834,
37.175823
],
"bearing_before":268.0,
"bearing_after":174.0,
"instruction":"Turn left to stay on Paseo del Generalife",
"type":"continue",
"modifier":"left"
},
"driving_side":"right",
"weight":73.85,
"intersections":[
{
"location":[
-3.589834,
37.175823
],
"bearings":[
88,
174,
307
],
"entry":[
false,
true,
false
],
"in":0,
"out":1
},
{
"location":[
-3.589829,
37.175777
],
"bearings":[
138,
231,
354
],
"entry":[
true,
false,
false
],
"in":2,
"out":0
}
]
},
{
"distance":665.0,
"duration":317.373,
"geometry":"cc~{eAdw`zEil@d_BcAvE}@vE{Ebl@aH`t@sFjj@e@fCyBbU}@dT?jG?xCbB|Sd@xF]zKaD`OeO~ZcAvBmFpKqG|R",
"name":"Paseo de los Coches",
"mode":"driving",
"maneuver":{
"location":[
-3.588995,
37.17485
],
""bearing_befor"

相关内容

  • 没有找到相关文章

最新更新