Polyline Algorithm

The route we return is encoded into a string using the Encoded Polyline Algorithm Format.

"route": [
    "mzsuFxusUA?I????FAF?F?H?@?B?F?@@V@F@H?H@F@BBJ??@HLj@DTDTFXDRR`ABNFZ@BFXJd@TjAf@zB??A??@A?A@A@?@A@?@?@A??@?@?@?@?@?@?@@@?@?@@??@?@@??@@??@@?@??@@?@?@?@?@?@A@?@A?A@??A@??AR?N@F?DADAJIBAHCTITITKh@Sr@Yv@[`@QFCDAFCHENKJIj@_@POvAcAr@i@XQJAFCB?b@[TQ@ATK??BBBB@@B@B@B@@@B?B?@?@?@?@?B?B?@?BA?AJGBE@CBE@GBG?G@G?IASAE?AAAAABCDG@E@E@C?G@I?GD_A?Aj@sFJ}@@]Cc@Fm@JcAFg@Fm@Fi@DWLqABWBQl@}FRkB^mDJkA@IHC@?BYDUF_@BM@IBQ?I?MD?@?@A@?@A@?@A@A@C@A??Le@BOBMBK?E?C@K?IAGAI??ZWJGd@]ZWh@a@RM~AiAPO^WpBwANMZS|AgAVSfAw@\\WVSFCBC@AFGFK??@??@@?F?@@B?B?B?BAB?@?@?@A@?@?@A@AB?@A@C@A@A?A@C@A?C@C?A?A@A?A?A?A?A"
],

You can use it directly in Mapbox or GMaps to get the waypoints painted automatically or you can use polyline decoding library to get the array of Locations:

[
  [ 40.41711, -3.70599 ],
  [ 40.41742, -3.7059 ],
  [ 40.41742, -3.7059 ],
  [ 40.41759, -3.70583 ]
]

Also, you can decode the route and see it on the map by using the Google Polyline Utility.
For example, if you’re using Node.js you can use the npm module Mapbox/polyline to decode the route. https://github.com/mapbox/polyline.

Install the module and require it like this:

mapbox_polyline = require('@mapbox/polyline');
//..
mapbox_polyline.decode(ROUTE-STRING)

Did this page help you?