Skip to content

Commit 18bd78a

Browse files
author
Nathan
committed
Merge pull request #3 from jamesdhutton/master
Fix to performance problem
2 parents ec4d110 + 2311ad6 commit 18bd78a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/leaflet.plotter.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ L.Polyline.plotter = L.Polyline.extend({
5555
}
5656
},
5757
_bindMapClick: function(){
58-
this._map.on('click', this._addNewMarker, this);
58+
this._map.on('click', this._onMapClick, this);
5959
},
6060
_unbindMapClick: function(){
61-
this._map.off('click', this._addNewMarker, this);
61+
this._map.off('click', this._onMapClick, this);
6262
},
6363
_setExistingLatLngs: function(latlngs){
6464
this._existingLatLngs = latlngs;
@@ -97,11 +97,14 @@ L.Polyline.plotter = L.Polyline.extend({
9797
this._lineMarkers.splice(this._lineMarkers.indexOf(e.target), 1);
9898
this._replot();
9999
},
100+
_onMapClick: function(e){
101+
this._addNewMarker(e);
102+
this._replot();
103+
},
100104
_addNewMarker: function(e){
101105
var newMarker = this._getNewMarker(e.latlng, { icon: this._editIcon });
102106
this._addToMapAndBindMarker(newMarker);
103107
this._lineMarkers.push(newMarker);
104-
this._replot();
105108
},
106109
_redrawHalfwayPoints: function(){
107110
for(index in this._halfwayPointMarkers){
@@ -139,6 +142,7 @@ L.Polyline.plotter = L.Polyline.extend({
139142
)
140143
});
141144
}
145+
this._replot();
142146
},
143147
_redraw: function(){
144148
this.setLatLngs([]);

0 commit comments

Comments
 (0)