From 07bcad409d79f8b9f6b82502ab25f7242446feee Mon Sep 17 00:00:00 2001 From: stefano bovio Date: Thu, 7 Sep 2023 18:26:29 +0200 Subject: [PATCH] #9366 Problems with Bearing measurement (#9400) --- .../map/openlayers/MeasurementSupport.jsx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/web/client/components/map/openlayers/MeasurementSupport.jsx b/web/client/components/map/openlayers/MeasurementSupport.jsx index efa19fc09a..8028a0eed1 100644 --- a/web/client/components/map/openlayers/MeasurementSupport.jsx +++ b/web/client/components/map/openlayers/MeasurementSupport.jsx @@ -26,6 +26,7 @@ import {getMessageById} from '../../../utils/LocaleUtils'; import {createOLGeometry} from '../../../utils/openlayers/DrawUtils'; import {Polygon, LineString} from 'ol/geom'; +import { never } from 'ol/events/condition'; import Overlay from 'ol/Overlay'; import VectorSource from 'ol/source/Vector'; import VectorLayer from 'ol/layer/Vector'; @@ -599,6 +600,7 @@ export default class MeasurementSupport extends React.Component { // create an interaction to draw with draw = new Draw({ source: new VectorSource(), + freehandCondition: never, type: /** @type {ol.geom.GeometryType} */ geometryType, style: new Style({ fill: new Fill({ @@ -621,9 +623,9 @@ export default class MeasurementSupport extends React.Component { }) }); - this.clickListener = this.props.map.on('click', this.updateMeasurementResults.bind(this, this.props)); + this.clickListener = this.props.map.on('click', this.updateMeasurementResults.bind(this)); if (this.props.updateOnMouseMove) { - this.props.map.on('pointermove', this.updateMeasurementResults.bind(this, this.props)); + this.props.map.on('pointermove', this.updateMeasurementResults.bind(this)); } this.props.map.on('pointermove', (evt) => this.pointerMoveHandler(evt)); @@ -896,10 +898,10 @@ export default class MeasurementSupport extends React.Component { this.props.map.removeInteraction(this.drawInteraction); this.drawInteraction = null; this.sketchFeature = null; - this.props.map.un('click', this.updateMeasurementResults.bind(this, this.props), this); + this.props.map.un('click', this.updateMeasurementResults.bind(this), this); unByKey(this.clickListener); if (this.props.updateOnMouseMove) { - this.props.map.un('pointermove', this.updateMeasurementResults.bind(this, this.props), this); + this.props.map.un('pointermove', this.updateMeasurementResults.bind(this), this); } } }; @@ -929,13 +931,13 @@ export default class MeasurementSupport extends React.Component { this.helpTooltipElement.classList.remove('hidden'); }; - updateMeasurementResults = (props) => { + updateMeasurementResults = () => { if (!this.sketchFeature) { return; } let sketchCoords = this.sketchFeature.getGeometry().getCoordinates(); - if (props.measurement.geomType === 'Bearing' && sketchCoords.length > 1) { + if (this.props.measurement.geomType === 'Bearing' && sketchCoords.length > 1) { // calculate the azimuth as base for bearing information if (sketchCoords.length > 2) { this.drawInteraction.sketchCoords_ = [sketchCoords[0], sketchCoords[1], sketchCoords[0]];