Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions geoengine_tools/static/src/js/geoengine_measure_tools.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,44 @@ patch(GeoengineRenderer.prototype, {
this._deactivateMeasureTools();
},

/**
* Reimplemented (vs base) only to exclude the measurement layer from the
* select interactions. Measure geometries carry no record, so selecting
* one would reach mountGeoengineRecord with undefined attributes and crash
* (evaluating 'attributes.id').
*/
registerInteraction() {
const notMeasureLayer = (layer) => layer !== this._measureLayer;
this.selectPointerMove = new ol.interaction.Select({
condition: ol.events.condition.pointerMove,
style: this.selectStyle,
layers: notMeasureLayer,
});
this.selectClick = new ol.interaction.Select({
condition: ol.events.condition.click,
style: this.selectStyle,
layers: notMeasureLayer,
});
this.selectClick.on("select", (e) => {
this.updateInfoBox(e.target.getFeatures());
});
this.map.addInteraction(this.selectClick);
this.map.addInteraction(this.selectPointerMove);
},

/**
* Safety net: ignore features without "attributes" (e.g. measurement
* geometries) so they never reach mountGeoengineRecord.
*/
updateInfoBox(features) {
const feature = features.item(0);
if (feature !== undefined && feature.get("attributes") === undefined) {
this.hidePopup();
return;
}
return super.updateInfoBox(...arguments);
},

// ---- Setup ----------------------------------------------------------

_setupMeasureControls() {
Expand Down
Loading