Skip to content

Commit 8c54ef4

Browse files
authored
Merge pull request #940 from ibi-group/fix-draw-on-drag
Don't Create Location Shape Points on Map Drag
2 parents 286a754 + 97525ab commit 8c54ef4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/editor/components/map/EditorMap.js

+10
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import React, {Component} from 'react'
44
import {Map, ZoomControl, FeatureGroup, GeoJSON} from 'react-leaflet'
55
import {shallowEqual} from 'react-pure-render'
6+
import L from 'leaflet'
67

78
import * as activeActions from '../../actions/active'
89
import * as editorActions from '../../actions/editor'
@@ -98,6 +99,15 @@ type State = {
9899
zoomToTarget: boolean
99100
}
100101

102+
// From https://github.com/Leaflet/Leaflet.draw/issues/695#issuecomment-281663243
103+
// Prevents creating a new leaflet draw point on drag
104+
const originalOnTouch = L.Draw.Polyline.prototype._onTouch
105+
L.Draw.Polyline.prototype._onTouch = function (e) {
106+
if (e.originalEvent.pointerType !== 'mouse') {
107+
return originalOnTouch.call(this, e)
108+
}
109+
}
110+
101111
export default class EditorMap extends Component<Props, State> {
102112
state = {
103113
width: 200,

0 commit comments

Comments
 (0)