mapboxmapbox-markermapbox-api-staticimages

Mapbox Static image with custom marker and polyline


I created a map with this API: https://docs.mapbox.com/api/maps/#static-images I used the "path" parameter with the polyline as well as the "url" parameter for the custom markers. The problem is that the path goes over the marker, is there a solution? Thanks

the trace goes under the marker


Solution

  • Per the API docs (here):

    The order of features in an overlay dictates their Z-order on the page. The last item in the list will have the highest Z-order (will overlap the other features in the list), and the first item in the list will have the lowest (will underlap the other features).

    So you can correct the behavior you are seeing by putting your path- overlay ahead of your url- marker overlay within the request, like so:

    https://api.mapbox.com/styles/v1/mapbox/streets-v11/static/path-{your path value},url-{your marker url}/auto/500x500?access_token={your.token}
    

    ⚠️ disclaimer: I currently work for Mapbox ⚠️