Chore: improve error handling

This commit is contained in:
Pieter Vander Vennet 2024-09-24 17:53:06 +02:00
parent 2bb38e0a61
commit 0c86df7a85

View file

@ -31,6 +31,7 @@ class PointRenderingLayer {
constructor( constructor(
map: MlMap, map: MlMap,
layer: LayerConfig,
features: FeatureSource, features: FeatureSource,
config: PointRenderingConfig, config: PointRenderingConfig,
metatags?: Store<Record<string, string>>, metatags?: Store<Record<string, string>>,
@ -47,7 +48,10 @@ class PointRenderingLayer {
this._onClick = onClick this._onClick = onClick
this._selectedElement = selectedElement this._selectedElement = selectedElement
const self = this const self = this
features.features.addCallbackAndRunD((features) => self.updateFeatures(features)) if(!features?.features){
throw "Could not setup a PointRenderingLayer; features?.features is undefined/null. The layer is "+layer.id
}
features.features?.addCallbackAndRunD((features) => self.updateFeatures(features))
visibility?.addCallbackAndRunD((visible) => { visibility?.addCallbackAndRunD((visible) => {
if (visible === true && self._dirty) { if (visible === true && self._dirty) {
self.updateFeatures(features.features.data) self.updateFeatures(features.features.data)
@ -601,6 +605,7 @@ export default class ShowDataLayer {
for (const pointRenderingConfig of this._options.layer.mapRendering) { for (const pointRenderingConfig of this._options.layer.mapRendering) {
new PointRenderingLayer( new PointRenderingLayer(
map, map,
this._options.layer,
features, features,
pointRenderingConfig, pointRenderingConfig,
this._options.metaTags, this._options.metaTags,