Я использую Google Maps Directions Api и библиотеку Google Maps Utils, чтобы нарисовать путь между моим местоположением и маркером, я извлекал поле overview-polyline из Directions Api, но нарисованная полилиния была неправильной, поэтому теперь я пытаюсь построить полилинию шаг за шагом, но я столкнулся с проблемой, я смог добавить в массив все полилинии, но теперь, как мне получить их из массива, чтобы декодировать и построить их;
Это JSON:
{
geocoded_waypoints: [
{},
{}
],
routes: [
{
bounds: {},
copyrights: "Dados do mapa ©2017 Google, Inst. Geogr. Nacional",
legs: [
{
distance: {},
duration: {},
end_address: "14 Avenue Latécoère, 31700 Cornebarrieu, França",
end_location: {},
start_address: "R. Zeferino Brandão 9, 2005 Santarém, Portugal",
start_location: {},
steps: [
{
distance: {},
duration: {},
end_location: {},
html_instructions: "Siga para <b>noroeste</b> na <b>R. Zeferino Brandão</b> em direção a <b>Tv. de São Domingos</b>",
polyline: {
points: "k|nnF`p_t@GB{@t@MFQPMLKXETEZCVCL?@?BAD?@?DAFC|@"
},
start_location: {},
travel_mode: "DRIVING"
},
{},
Вот как я расшифровал overview-polyline а>:
...
JSONObject singleRout = (JSONObject) routes.get(0);
JSONObject overview_polyline = (JSONObject) singleRout.get("overview_polyline");
if (overview_polyline != null) {
points = overview_polyline.getString("points");
}
...
protected void fazerCaminho() {
List<LatLng> decodedPath = PolyUtil.decode(points);
if (line == null) {
line = mMap.addPolyline(new PolylineOptions()
.width(3)
.color(Color.rgb(25, 151, 152))
.geodesic(true)
.addAll(decodedPath));
} else {
line.remove();
line = mMap.addPolyline(new PolylineOptions()
.width(3)
.color(Color.rgb(25, 151, 152))
.geodesic(true)
.addAll(decodedPath));
}
}
Теперь я добавляю все точки в список массивов следующим образом:
JSONObject singlePolyline = (JSONObject) singleStep.get("polyline");
if (singlePolyline != null) {
points = singlePolyline.getString("points");
caminho.put("points" , points);
}
listaPolylines.add(caminho);
Как теперь расшифровать значения из списка?