+ selectFeatures(layerName, featureIds) {
+ // we cannot use 'this' in the function provided to OpenLayers
+ let mapPart = this;
+ this.select.getFeatures().clear();
+ const layer = this.getLayerByName(layerName);
+ const source = layer.getSource();
+ for (const featureId of featureIds) {
+ let feature = source.getFeatureById(featureId);
+ if (feature === null) {
+ source.on('featuresloadend', function(e) {
+ feature = source.getFeatureById(featureId);
+ if (feature !== null)
+ mapPart.select.getFeatures().push(feature);
+ });
+ } else {
+ this.select.getFeatures().push(feature);
+ }
+ }
+ }
+
+ fitToLayer(layerName) {
+ // we cannot use 'this' in the function provided to OpenLayers
+ let mapPart = this;
+ const layer = this.getLayerByName(layerName);
+ const source = layer.getSource();
+ const extent = source.getExtent();
+ const options = {
+ duration: 1000,
+ padding: [20, 20, 20, 20],
+ easing: easeOut,
+ };
+ if (!isEmpty(extent))
+ this.#map.getView().fit(source.getExtent(), options);
+ source.on('featuresloadend', function(e) {
+ mapPart.getMap().getView().fit(source.getExtent(), options);
+ });
+ }
+