I am currently using Mapbox GL JS and pull multiple GeoJson files from the style.json file. Each file in about 10MB and takes too long to load. Is there a way to compress the files and uncompressed them in Mapbox?


The best way is probably converting the geojson to mbtiles. Mbtiles are more compact overall due to their protobuf format, and faster on initial load since only the visible part is requested. I'd recommend Tippecanoe for that. If you need the entire files in memory (e.g. for querySourceFeatures), you might convert the geojson to topojson, or gzip the files.

  • thanks. If I compress the files to gzip, How do I pull them from the style.json file?
    – ronaron
    Oct 19 '17 at 15:39
  • Clarification: are you grabbing geojson file/objects from a larger style.json file/object? Are you doing this via network or filesystem? Oct 19 '17 at 15:45
  • I have style.json which pulls geojson files as sources from my server.
    – ronaron
    Oct 19 '17 at 19:42
  • If they are remote HTTP sources just enable use Content Encoding on the server en.wikipedia.org/wiki/HTTP_compression ? Oct 20 '17 at 0:25
  • It is S3 bucket not a server. @AndrewHarvey
    – ronaron
    Oct 20 '17 at 3:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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