Я пытаюсь сделать массив из данных с машины маршрутизации листовок.Мне нужно, чтобы он был в следующем формате:
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[
-122.404947281,
37.7815184928,
0
],
[
-122.409410477,
37.7780078698,
0
],
[
-122.510712147,
37.7691033683,
0
]
]
},
"properties": {
"name": "\n"
}
}
]
}
Но я могу получить только это: Вывод:
{"type":"LineString","coordinates":[[-1.55654,52.41007,0],[-1.5567,52.41003,0],[-1.55674,52.41002,0],[-1.55677,52.40999,0],[-1.55445,52.413,0]]}
Код из при использовании leaflet.routine.machine
myroutewithout.on('routeselected', function(e) {
var lineCoordinates = [],
i,
latLng;
for (i = 0; i < e.route.coordinates.length; i++) {
latLng = L.latLng(e.route.coordinates[i]);
lineCoordinates.push([latLng.lng, latLng.lat, 0]);
}
var json = {
type: "FeatureCollection",
features: [],
type: 'LineString',
coordinates: lineCoordinates
};
var jsonExport = JSON.stringify(json)
console.log(jsonExport);
});
Как добавить дополнительный материал в начале?