The route is created using the HERE Routing API. This API returns a flexible polyline.
This is an example:
BGwynmkDu39wZvBtFAA3InfAAvHrdAAvHvbAAoGzF0FnGoGvHsOvRAA8L3NAAkSnVAAoGjIsEzFAAgFvHkDrJAAwHrJoVvb0ezoBAAjInVAA3N_iBAAzJ_Z
The size of the flexible polyline depends on the length of the route. This flexible polyline corresponds to a route of 550 metres. For a route of 725 km, the flexible polyline is 71 001 characters long.
To display the route on a map, I need to transform a flexible polyline into two lists of GPS coordinates:
I also created a custom state called “coordinates” (a text list) and a workflow with the “Run javascript” action. In this action I added the following code:
var flexiblePolylineData = H.util.flexiblePolyline.decode(Input Polyline’s value);
var lineString = new H.geo.LineString();
flexiblePolylineData.polyline.forEach(p => lineString.pushPoint({lat: p[0], lng: p[1]}));
Bubble_fn_value(lineString.getLatLngArray());
What do you want to do with the array of points that you are sending from JS to Bubble? The answer will help determine how to represent the data.
For example, if they are only used to draw on the map, then there is no need to send them to Bubble.
Fixing your test app …
Run javascript - turn off “Asynchronous” so that subsequent steps don’t look for a value that has been deferred
Run javascript - fixes to the script
var flexiblePolylineData = H.util.flexiblePolyline.decode(Input Polyline’s value);
// need quotes around the string parameter
var flexiblePolylineData = H.util.flexiblePolyline.decode("Input Polyline’s value");
Bubble_fn_value(lineString.getLatLngArray());
// change Bubble_fn to bubble_fn
// change getLatLngArray to getLatLngAltArray
bubble_fn_value(lineString.getLatLngAltArray());
Change Javascript to Bubble to output list of numbers
Change custom state to store list of numbers
You’ll find javascript is pedantic about its syntax!
transform a flexible polyline into a list of GPS coordinates.
use the GPS coordinates to display the route on a map using the Leafy Map plugin.
Initially, I wanted to use a feature of the plugin that takes a polyline and automatically plots the route, but this feature no longer works and probably won’t be fixed.
In the example above, I have tried to display three lists: the first for GPS coordinates (Lat Lng Alt), the second for latitudes and the third for longitudes. But all three lists are completed with the GPS coordinates values.
I can’t see what I’m missing. What do you think?
Here are some captures of my app (I’m sorry I can’t share the link to the app).
There were some bugs in the older version of Toolbox plugin, so sorry!! To get the fixes to multi output lists, update the plugin to the latest version.
I notice your list of numbers is displaying a comma as the decimal point, i.e. 52,8886
This is fine so long as you keep the numbers in number form. But if sending the number as text to for example an API or plugin that takes a number in a text form, take care to format to text with a period for the decimal, for example 52.8886