CSBP-CPSE / web-mapping-components

Other
2 stars 2 forks source link

Validate Data On Load #20

Closed Noznoc closed 3 years ago

Noznoc commented 3 years ago

Robert:

I did see a console error when I tried to load a new map style document from mapbox which uses geojson datasets (i.e. when we change the map from one dataset to the another which uses geojson datasets hosted on mapbox (e.g. odhf)) but from debugging I haven't found the reason for it occurring yet, and the layer still displays as expected on the map.

I suspect the cause of the issue is that the data isn't fully downloaded before it tries to update the layer styling, but I'll look into it further when time allows. More than likely we will need to expand the code to be bit when using external data sources, which we would likely need to do anyway since we are moving to our own db host. e.g. If maplibre doesn't do this already, our code should check if we have all of the data before we try to update the map layers which use that external data.

roikle commented 3 years ago

Mapbox provides numerous built-in map events relating to processing source data. See mapbox-gl api docs for additional information.

Examples of map data events: data, dataloading, sourcedata, and souredataloading.

According to map data event documentation, data events have a property isSourceLoaded which could be used in a condition to then continue loading the next source data file. Once all source data has been loaded, you could then add map layers which have sources.

roikle commented 3 years ago

Added mapbox sourcedata event to the map module (see commit 36b1cd36afe7becbccdec5604e1cf496fb3bd9fb). Now when making an application a developer can load each data source, and confirm when the source is loaded before using it.