Skip to content

Commit 95cdcd3

Browse files
fix: don’t draw points on drag
1 parent 286a754 commit 95cdcd3

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'
@@ -121,6 +122,15 @@ export default class EditorMap extends Component<Props, State> {
121122
componentDidMount () {
122123
window.addEventListener('resize', this._onResize)
123124
this.setState({willMount: false})
125+
126+
// From https://github.com/Leaflet/Leaflet.draw/issues/695#issuecomment-281663243
127+
// Prevents creating a new leaflet draw point on drag
128+
var originalOnTouch = L.Draw.Polyline.prototype._onTouch;
129+
L.Draw.Polyline.prototype._onTouch = function (e) {
130+
if (e.originalEvent.pointerType != "mouse") {
131+
return originalOnTouch.call(this, e);
132+
}
133+
};
124134
}
125135

126136
componentWillUnmount () {

0 commit comments

Comments
 (0)