2

Whenever I try to add a polyline between points of equal latitude, Mapbox responds with an error (example shown below). If I change the latitude of one of the points by 0.00001 degrees, then it works fine.

Does anyone understand why?

Example: Try to add a polyline between the points (40, -90) and (40, -91). Using Google’s Interactive Polyline Encoder Utility, as shown in screenshot below, gives the following encoded polyline: _ocsF~bidP?~hbE
enter image description here

But when using this encoded polyline in a request, Mapbox responds with an error as described below:
Request:
https://api.mapbox.com/styles/v1/mapbox/streets-v11/static/path-1+e00-2(_ocsF~bidP?~hbE)/-90,40,7,0,0/500x400?access_token=YOUR_MAPBOX_ACCESS_TOKEN
Response: {"message":"Not Authorized - No Token"}

Now change the latitude of the second point to 40.00001. Using Google’s Interactive Polyline Encoder Utility gives the following encoded polyline: _ocsF~bidPA~hbE
enter image description here

And using this encoded polyline in a request returns the image I expect:
Request:
https://api.mapbox.com/styles/v1/mapbox/streets-v11/static/path-1+e00-2(_ocsF~bidPA~hbE)/-90,40,7,0,0/500x400?access_token=YOUR_MAPBOX_ACCESS_TOKEN
Response:
enter image description here

2
  • I would write to Mapbox support and ask if you have found a bug. Your encoded overlay seems to be valid docs.mapbox.com/api/maps/#overlay-options.
    – user30184
    Commented Aug 21, 2019 at 18:05
  • Good idea, @user30184. I emailed Mapbox. I'll update here with any helpful information they provide. Commented Aug 21, 2019 at 18:30

2 Answers 2

1

Good news...Mapbox support was very helpful! It turns out that the problem arises from the question mark character in the encoded polyline. If you replace the ? with %3F it works just fine!

0

use encodeURIComponent() function before passing the encoded Polyline in the url

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.