Mapbox static map large dataset

Viewed 499
1 Answers

As explained in the documentation :

Using a large GeoJSON object as an argument to the overlay parameter may result in hitting the 8,192 byte URL length limit. Possible options for shortening the resulting URL length include:

  • Simplifying your GeoJSON using a third party library, such as simplify-geojson, before passing it as an argument.
  • Limiting the precision of the coordinates in the GeoJSON to no more than five to six decimals places, which would allow you to make use of more points in the GeoJSON itself.

But it's possible your file track (geojson, gpx,... whatever) is so big that all options above are not efficient to reduce it under the characters limit.

So the last solution is the one below. First upload your file as tileset (not dataset as you did), add it as a layer to a custom style and then generate the static map from it.

  • If the GeoJSON consists of a large and detailed polygon, you could create a custom style in Mapbox Studio including the polygon, and pass the resulting style ID to the style_id parameter of the Static Images API instead of using the overlay parameter. First upload the GeoJSON to Mapbox as a tileset, and then add it as a layer in a custom style. Reference this tutorial for guidance.

Source : https://docs.mapbox.com/api/maps/#static-images

So first, you need to learn how to upload your file on your MapBox account : https://docs.mapbox.com/help/how-mapbox-works/uploading-data/

I know the post is old, hope it will help other developers. Sorry for my english, Thomas

Related