Я хотел бы показать маршрут на карте с лифтом.Как отображать полилинии «Google API» с лифтом?
Для этого я делаю запрос на API API карт Google. Я получаю JSON как это:
{
"routes" : [
{
"bounds" : {
"northeast" : {
"lat" : 51.5103406,
"lng" : -0.0627423
},
"southwest" : {
"lat" : 51.5049264,
"lng" : -0.0898856
}
},
"copyrights" : "Données cartographiques ©2014 Google",
"legs" : [
{
"distance" : {
"text" : "3,0 km",
"value" : 2959
},
"duration" : {
"text" : "7 minutes",
"value" : 427
},
"end_address" : "29 Fowey Close, Londres E1W 2JP, Royaume-Uni",
"end_location" : {
"lat" : 51.5064421,
"lng" : -0.0627423
},
"start_address" : "8 Southwark Street, Londres SE1 1TL, Royaume-Uni",
"start_location" : {
"lat" : 51.5049264,
"lng" : -0.0898856
},
"steps" : [
{
"distance" : {
"text" : "0,6 km",
"value" : 601
},
"duration" : {
"text" : "1 minute",
"value" : 77
},
"end_location" : {
"lat" : 51.5099409,
"lng" : -0.0870841
},
"html_instructions" : "Prendre la direction \u003cb\u003enord-est\u003c/b\u003e sur \u003cb\u003eBorough High St/A3\u003c/b\u003e vers \u003cb\u003eBedale St\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003eContinuer de suivre A3\u003c/div\u003e\u003cdiv style=\"font-size:0.9em\"\u003eEntrée dans une section à péage\u003c/div\u003e",
"polyline" : {
"points" : "[email protected]@[email protected]][email protected]@[email protected]@[email protected]"
},
"start_location" : {
"lat" : 51.5049264,
"lng" : -0.0898856
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0,2 km",
"value" : 152
},
"duration" : {
"text" : "1 minute",
"value" : 25
},
"end_location" : {
"lat" : 51.50989,
"lng" : -0.0883307
},
"html_instructions" : "Prendre légèrement \u003cb\u003eà gauche\u003c/b\u003e sur \u003cb\u003eArthur St\u003c/b\u003e",
"maneuver" : "turn-slight-left",
"polyline" : {
"points" : "[email protected][email protected][email protected]"
},
"start_location" : {
"lat" : 51.5099409,
"lng" : -0.0870841
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0,6 km",
"value" : 590
},
"duration" : {
"text" : "1 minute",
"value" : 72
},
"end_location" : {
"lat" : 51.50955829999999,
"lng" : -0.080139
},
"html_instructions" : "Prendre \u003cb\u003eà gauche\u003c/b\u003e sur \u003cb\u003eUpper Thames St/A3211\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003eContinuer de suivre A3211\u003c/div\u003e",
"maneuver" : "turn-left",
"polyline" : {
"points" : "yokyH`gPZ}[email protected]@H}@[email protected]_CRsDJuAJiB\\[email protected][email protected]@[email protected][email protected]@[email protected]@[email protected]"
},
"start_location" : {
"lat" : 51.50989,
"lng" : -0.0883307
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0,5 km",
"value" : 498
},
"duration" : {
"text" : "1 minute",
"value" : 73
},
"end_location" : {
"lat" : 51.5093097,
"lng" : -0.0737046
},
"html_instructions" : "Continuer sur \u003cb\u003eByward St/A100\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003eContinuer de suivre A100\u003c/div\u003e\u003cdiv style=\"font-size:0.9em\"\u003eSortie de section à péage dans 400 m, au niveau de Minories/A1211\u003c/div\u003e",
"polyline" : {
"points" : "wmkyHzsNG[[email protected][email protected]@@[email protected][email protected]@[email protected]][email protected]@AQM{[email protected]@{[email protected]"
},
"start_location" : {
"lat" : 51.50955829999999,
"lng" : -0.080139
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0,5 km",
"value" : 472
},
"duration" : {
"text" : "1 minute",
"value" : 54
},
"end_location" : {
"lat" : 51.5090739,
"lng" : -0.06770899999999999
},
"html_instructions" : "Continuer sur \u003cb\u003eMinories/A1203\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003eContinuer de suivre A1203\u003c/div\u003e",
"polyline" : {
"points" : "[email protected]@VgAT}@[email protected]@FWDOD]B]?W?WASAWM_B][email protected]@[email protected]@uC"
},
"start_location" : {
"lat" : 51.5093097,
"lng" : -0.0737046
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0,3 km",
"value" : 297
},
"duration" : {
"text" : "1 minute",
"value" : 57
},
"end_location" : {
"lat" : 51.5065805,
"lng" : -0.0666981
},
"html_instructions" : "Prendre \u003cb\u003eà droite\u003c/b\u003e sur \u003cb\u003eVaughan Way\u003c/b\u003e",
"maneuver" : "turn-right",
"polyline" : {
"points" : "ujkyHdfL`[email protected][email protected]@[email protected][email protected]?`@[email protected]?\\F"
},
"start_location" : {
"lat" : 51.5090739,
"lng" : -0.06770899999999999
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0,3 km",
"value" : 272
},
"duration" : {
"text" : "1 minute",
"value" : 41
},
"end_location" : {
"lat" : 51.5068938,
"lng" : -0.0629257
},
"html_instructions" : "Prendre \u003cb\u003eà gauche\u003c/b\u003e sur \u003cb\u003eKennet St\u003c/b\u003e",
"maneuver" : "turn-left",
"polyline" : {
"points" : "c{jyHz_LASASAKCMM][email protected][email protected]@[email protected]"
},
"start_location" : {
"lat" : 51.5065805,
"lng" : -0.0666981
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "77 m",
"value" : 77
},
"duration" : {
"text" : "1 minute",
"value" : 28
},
"end_location" : {
"lat" : 51.5064421,
"lng" : -0.0627423
},
"html_instructions" : "Prendre \u003cb\u003eà droite\u003c/b\u003e sur \u003cb\u003eFowey Close\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003eVotre destination se trouvera sur la droite\u003c/div\u003e",
"maneuver" : "turn-right",
"polyline" : {
"points" : "a}[email protected]@G?ECEMG"
},
"start_location" : {
"lat" : 51.5068938,
"lng" : -0.0629257
},
"travel_mode" : "DRIVING"
}
],
"via_waypoint" : []
}
],
"overview_polyline" : {
"points" : "[email protected]@[email protected]@[email protected]@[[email protected]@[email protected]]qA[[email protected][email protected]^[email protected]}DL}ALiB|@sN^[email protected]@AgADmC\\kC?[[email protected][email protected]][email protected]@[email protected]@[email protected]@[email protected]@H{@[email protected]@[email protected]@[email protected]}@[email protected]@[email protected]@[email protected]?\\[email protected]@[email protected]@[email protected]"
},
"summary" : "A3",
"warnings" : [],
"waypoint_order" : []
}
],
"status" : "OK"
};
Я вижу, что есть некоторые поля полилинии с некоторыми странными в нем данных, но я не знаю, что он представляет. Как я могу их отобразить?
Вы имеете в виду 'полилиния ['points']'? Я не вижу связи между вопросом в названии и вопросом в конце. – MrUpsidown
@MrUpsidown Да, я хотел бы отобразить полилинию, представляющую маршрут на карте с помощью листовки –
Ну, я не знаю о leaflet.js, но из документа, похоже, вы можете создать «полилинию», которая принимает * массив географических точек * http://leafletjs.com/reference.html#polyline Итак, вам в основном нужно получить координаты каждого шага из ответа и передать его в листовку 'polyline' – MrUpsidown