diff --git a/components/map/OlMap.jsx b/components/map/OlMap.jsx index db49ee0dc..e8fb8f12f 100644 --- a/components/map/OlMap.jsx +++ b/components/map/OlMap.jsx @@ -349,6 +349,9 @@ class OlMap extends React.Component { MapUtils.registerHook(MapUtils.GET_COORDINATES_FROM_PIXEL_HOOK, (pixel) => { return this.map.getCoordinateFromPixel(pixel); }); + MapUtils.registerHook(MapUtils.GET_SNAPPED_COORDINATES_FROM_PIXEL_HOOK, (pixel) => { + return this.map.getCoordinateFromPixel(pixel); + }); MapUtils.registerHook(MapUtils.GET_NATIVE_LAYER, (id) => { return this.map.getLayers().getArray().find(layer => layer.get('id') === id); }); diff --git a/plugins/map/RedliningSupport.jsx b/plugins/map/RedliningSupport.jsx index acdaf04cf..effc0c142 100644 --- a/plugins/map/RedliningSupport.jsx +++ b/plugins/map/RedliningSupport.jsx @@ -400,7 +400,7 @@ class RedliningSupport extends React.Component { this.interactions.push(drawInteraction); this.picking = false; - const clickCoord = MapUtils.getHook(MapUtils.GET_COORDINATES_FROM_PIXEL_HOOK)(ev.pixel); + const clickCoord = MapUtils.getHook(MapUtils.GET_SNAPPED_COORDINATES_FROM_PIXEL_HOOK)(ev.pixel); drawInteraction.appendCoordinates([clickCoord]); if (this.props.redlining.geomType === 'Point') { drawInteraction.finishDrawing(); diff --git a/plugins/map/SnappingSupport.jsx b/plugins/map/SnappingSupport.jsx index 0e258b0f0..f2c014c66 100644 --- a/plugins/map/SnappingSupport.jsx +++ b/plugins/map/SnappingSupport.jsx @@ -58,6 +58,11 @@ class SnappingSupport extends React.Component { props.map.getInteractions().on('add', this.handleInteractionAdded); props.map.getInteractions().on('remove', this.handleInteractionRemoved); + MapUtils.registerHook(MapUtils.GET_SNAPPED_COORDINATES_FROM_PIXEL_HOOK, (pixel) => { + const coo = props.map.getCoordinateFromPixel(pixel); + const snapResult = this.snapInteraction.snapTo(pixel, coo, props.map); + return snapResult ? props.map.getCoordinateFromPixel(snapResult.vertexPixel) : coo; + }); } componentDidUpdate(prevProps, prevState) { if (this.state.drawing && (this.props.mapObj.bbox !== prevProps.mapObj.bbox || this.props.theme !== prevProps.theme)) {