diff --git a/web/client/components/map/leaflet/MeasurementSupport.jsx b/web/client/components/map/leaflet/MeasurementSupport.jsx index d196d78c2b..ffeaed6b59 100644 --- a/web/client/components/map/leaflet/MeasurementSupport.jsx +++ b/web/client/components/map/leaflet/MeasurementSupport.jsx @@ -121,26 +121,16 @@ const MeasurementSupport = React.createClass({ } else { let bearingMarkers = this.drawControl._markers || []; - if (bearingMarkers.length <= 2 ) { + if (this.props.measurement.geomType === 'Bearing' && bearingMarkers.length >= 2) { + this.drawControl._markers = slice(this.drawControl._markers, 0, 2); + this.drawControl._poly._latlngs = slice(this.drawControl._poly._latlngs, 0, 2); + this.drawControl._poly._originalPoints = slice(this.drawControl._poly._originalPoints, 0, 2); this.updateMeasurementResults(); - } - if (bearingMarkers.length === 2 && this.props.measurement.geomType === 'Bearing') { this.drawControl._finishShape(); this.drawControl.disable(); this.drawing = false; - } - if (bearingMarkers.length > 2) { - if (this.props.measurement.geomType === 'Bearing') { - this.drawControl._markers = slice(this.drawControl._markers, 0, 2); - this.drawControl._poly._latlngs = slice(this.drawControl._poly._latlngs, 0, 2); - this.drawControl._poly._originalPoints = slice(this.drawControl._poly._originalPoints, 0, 2); - this.updateMeasurementResults(); - this.drawControl._finishShape(); - this.drawControl.disable(); - this.drawing = false; - } else { - this.updateMeasurementResults(); - } + } else { + this.updateMeasurementResults(); } } }, diff --git a/web/client/components/map/openlayers/MeasurementSupport.jsx b/web/client/components/map/openlayers/MeasurementSupport.jsx index c932b45d37..f6dcc75f8f 100644 --- a/web/client/components/map/openlayers/MeasurementSupport.jsx +++ b/web/client/components/map/openlayers/MeasurementSupport.jsx @@ -142,12 +142,12 @@ const MeasurementSupport = React.createClass({ let bearing = 0; let sketchCoords = this.sketchFeature.getGeometry().getCoordinates(); - if (this.props.measurement.geomType === 'Bearing' && - sketchCoords.length > 1) { + if (this.props.measurement.geomType === 'Bearing' && sketchCoords.length > 1) { // calculate the azimuth as base for bearing information bearing = CoordinatesUtils.calculateAzimuth(sketchCoords[0], sketchCoords[1], this.props.projection); if (sketchCoords.length > 2) { this.drawInteraction.sketchCoords_ = [sketchCoords[0], sketchCoords[1], sketchCoords[0]]; + this.sketchFeature.getGeometry().setCoordinates(this.drawInteraction.sketchCoords_); this.drawInteraction.finishDrawing(); } }