kotlinmapboxmapbox-static-maps

Display image of encode polyline in Mapbox


I have a encoded polyline like this: ki{eFvqfiVsBmA`Feh@qg@iX`B}JeCcCqGjIq~@kf@cM{KeHeX`@_GdGkSeBiXtB}YuEkPwFyDeAzAe@pC~DfGc@bIOsGmCcEiD~@oBuEkFhBcBmDiEfAVuDiAuD}NnDaNiIlCyDD_CtJKv@wGhD]YyEzBo@g@uKxGmHpCGtEtI~AuLrHkAcAaIvEgH_EaDR_FpBuBg@sNxHqEtHgLoTpIiCzKNr. Now I want it to display a static image of the path using Mapbox with Kotlin.

I have tried Mapbox Static Url to get the image but it always return the following error: {"message": "Not found"}. I have remove the special characters from the url to make it a valid url but then also giving above error.

Now how can I get the image successfully is there anything regarding encoding or decoding the polyline into coordinates if yes then how can i do it? Or is there something else I am missing?


Solution

  • I have found a way for those who need I am asnwering here for Mapbox only.

    https://api.mapbox.com/styles/v1/mapbox/streets-v12/static/path-5+f44-0.5(enocoded_polyline_here)/auto/100x100?access_token=your_mapbox_access_token_here

    You can just use this link with replacing the placeholder, but make sure that you encode the polyline before using it otherwise it can cause problem reported at: Static image api is not working in some cases

    NOTE: You can change the style of the map using the link styling by referring to the mapbox docs.