In Google Maps Directions API it is possible to get the waypoints from one coordinate to another coordinate as polyline:
https://developers.google.com/maps/documentation/directions/
Request example:
Google returns a JSON (because I have requested a JSON) with several information - including waypoints in an encoded format (see line 63, 87 and 101):
{ "geocoded_waypoints" : [ { "geocoder_status" : "OK", "place_id" : "EipLaXJjaGJhY2hlciBTdHIuIDk5LTEyMiwgODA4MSwgw5ZzdGVycmVpY2g", "types" : [ "street_address" ] }, { "geocoder_status" : "OK", "place_id" : "Ej1HdWdnaXR6IEJlcmd3ZWcgNTQsIDgwODEgUGlyY2hpbmcgYW0gVHJhdWJlbmJlcmcsIMOWc3RlcnJlaWNo", "types" : [ "street_address" ] } ], "routes" : [ { "bounds" : { "northeast" : { "lat" : 46.9774785, "lng" : 15.6212531 }, "southwest" : { "lat" : 46.9746073, "lng" : 15.6144114 } }, "copyrights" : "Kartendaten © 2018 Google", "legs" : [ { "distance" : { "text" : "0,8 km", "value" : 811 }, "duration" : { "text" : "1 Minute", "value" : 81 }, "end_address" : "Guggitz Bergweg 54, 8081 Pirching am Traubenberg, Österreich", "end_location" : { "lat" : 46.9752518, "lng" : 15.6144114 }, "start_address" : "Kirchbacher Str. 99-122, 8081, Österreich", "start_location" : { "lat" : 46.9746073, "lng" : 15.6212531 }, "steps" : [ { "distance" : { "text" : "0,4 km", "value" : 361 }, "duration" : { "text" : "1 Minute", "value" : 20 }, "end_location" : { "lat" : 46.9774785, "lng" : 15.61923 }, "html_instructions" : "Auf u003cbu003eKirchbacher Str.u003c/bu003e/u003cbu003eB73u003c/bu003e nach u003cbu003eNordwestenu003c/bu003e Richtung u003cbu003eGuggitz Bergwegu003c/bu003e starten", "polyline" : { "points" : "ivu}Gy_j~ASR]RuBh@{@Rg@PGBc@Ra@TUN_@V{AlAY^MPMRQ\\IR" }, "start_location" : { "lat" : 46.9746073, "lng" : 15.6212531 }, "travel_mode" : "DRIVING" }, { "distance" : { "text" : "0,4 km", "value" : 450 }, "duration" : { "text" : "1 Minute", "value" : 61 }, "end_location" : { "lat" : 46.9752518, "lng" : 15.6144114 }, "html_instructions" : "u003cbu003eLinksu003c/bu003e abbiegen auf u003cbu003eGuggitz Bergwegu003c/bu003e", "maneuver" : "turn-left", "polyline" : { "points" : "ghv}Gesi~ALh@X`CzAfHp@hBfA|BJPnAzBr@fAPT\\Z" }, "start_location" : { "lat" : 46.9774785, "lng" : 15.61923 }, "travel_mode" : "DRIVING" } ], "traffic_speed_entry" : [], "via_waypoint" : [] } ], "overview_polyline" : { "points" : "ivu}Gy_j~ASR]RqD|@o@TeAh@u@f@{AlAY^[d@[p@Lh@X`CzAfHp@hBrAnCnAzBr@fAn@p@" }, "summary" : "Kirchbacher Str./B73 und Guggitz Bergweg", "warnings" : [], "waypoint_order" : [] } ], "status" : "OK" }
See the algorithm of Google to encode this, so it should be possible to decode the string when dooing the step in the other direction:
https://developers.google.com/maps/documentation/utilities/polylinealgorithm
On this page is an example of a JavaScript code to decode the polyline string:
https://stackoverflow.com/questions/40877840/google-maps-api-draw-a-route-using-points-of-a-polyline
But unfortunately it's not possible to include the JavaScript library in the JavaScriptCaller:
https://maps.googleapis.com/maps/api/js?libraries=geometry
Because JavaScript seems not to be fully supported by the JavaScriptCaller, it would be great to do the decoding via GeometryExtractor or GeometryReplacer.
There are already a lot of encodings (GeometryExtractor > Parameters > Geometry Encoding):