1
votes

Is there any guidance information with regards to handling fairly large (5MB) GeoJSON datasets in mapbox?

I have 3-4 which I need to show and switch between on one map. Am I best to combine the data sources and use a filter on the layer to select the data I want? or would it be better to create 3-4 layers and show/hide based on need? or would it be best to have a single layer and feed in the data via setData on the layer?

1

1 Answers

1
votes

The answer to this question depends on what your performance bottleneck is:

  • If your bottleneck is transferring data to/from the worker threads, using setFilter will eliminate the need to transfer data to the worker threads.
  • If your bottleneck is filtering data in the worker threads and you can preprocess that data more efficiently, using setData will eliminate the need to filter data on the worker threads.
  • If you have lots of memory available and need to show/hide layers quickly, creating 3-4 separate layers and showing/hiding based on need will be best

Your bottleneck will depend on your data, your usage patterns, and your device. As always, I recommend doing whatever is easiest & profiling if perf isn'f good enough!