how can I render the L.featureGroup from an array of coordinateRoute in data.json, to handle with button "Snake it!", It's like when I click on "snake it!" has it's own id and the map will show Polyline of the coordinateRoute with corresponding id
Here's data.json:
tobe more Specifically this is how I try but WRONG:
let route;
data.map((item) => {
if (item.id === 1 && item.coordinateRoute) {
return (route = L.featureGroup([
item.coordinateRoute.map((line) => {
if (i % 2 === 0) {
L.marker(item.coordinateRoute[i], { icon });
}
L.polyline([item.coordinateRoute[i], item.coordinateRoute[i + 1]]);
return i++;
}),
]));
return (route = L.featureGroup(lines));
}
return route;
});