routePolyline = {
nextbillion.setApiKey(apiKey);
const directionsService = new nextbillion.maps.DirectionsService();
let resp = await directionsService.route({
origin: {
lng: panel.originPoint.split(",")[1],
lat: panel.originPoint.split(",")[0]
},
destination: {
lng: panel.destinationPoint.split(",")[1],
lat: panel.destinationPoint.split(",")[0]
},
mode: panel.routeStyle.value
});
let geojson = {
type: "FeatureCollection",
features: [
{
type: "Feature",
properties: {},
geometry: {
coordinates: nextbillion.utils.polyline
.decode(resp.routes[0].geometry, 6)
.map((c) => c.reverse()),
type: "LineString"
}
}
]
};
let options = { tolerance: 0.001, highQuality: false };
let generalized = turf.simplify(geojson, options);
return generalized;
}