Closed niclashoyer closed 5 years ago
I think I found the problem, the following code assumes that byte
is an unsigned value:
byte = str.charCodeAt(index++) - 63;
But if the latitude or longitude does not change, this evaluates to -1
which leads to wrong values down the line. I added a Math.max(..., 0)
to mitigate this. See #55.
Nevermind, my encoding function on the server side is wrong. It somehow generated the character <
which is 62
in decimal.
I've got a somewhat simple polyline string that I want to decode (used as a route in mapbox-gl-directions):
Rendering this route with mapbox-gl-directions results in this:
Decoding the same polyline string with the Google polyline utility results in the correct polyline:
As far as I could debug, the latitude is wrong at two points, while the longitude is correct. It seems that the decoding is wrong if the latitude does not change between two points. I'd need to dig a bit further into the decoding to verify this.