Skip to content

Commit 4a0417d

Browse files
committed
better fix for #41
1 parent cccb4b0 commit 4a0417d

File tree

3 files changed

+35
-15
lines changed

3 files changed

+35
-15
lines changed

dist/leaflet.pm.js

+17-7
Original file line numberDiff line numberDiff line change
@@ -459,9 +459,26 @@ L.PM.Edit.Poly = L.Class.extend({
459459
rightM._middleMarkerLeft = middleMarker;
460460

461461
middleMarker.on('click', function() {
462+
463+
// TODO: move the next two lines inside _addMarker() as soon as
464+
// https://github.com/Leaflet/Leaflet/issues/4484
465+
// is fixed
466+
var icon = L.divIcon({className: 'marker-icon'});
467+
middleMarker.setIcon(icon);
468+
462469
self._addMarker(middleMarker, leftM, rightM);
463470
});
464471
middleMarker.on('movestart', function() {
472+
473+
// TODO: This is a workaround. Remove the moveend listener and callback as soon as this is fixed:
474+
// https://github.com/Leaflet/Leaflet/issues/4484
475+
middleMarker.on('moveend', function() {
476+
var icon = L.divIcon({className: 'marker-icon'});
477+
middleMarker.setIcon(icon);
478+
479+
middleMarker.off('moveend');
480+
});
481+
465482
self._addMarker(middleMarker, leftM, rightM);
466483
});
467484

@@ -475,13 +492,6 @@ L.PM.Edit.Poly = L.Class.extend({
475492
newM.off('movestart');
476493
newM.off('click');
477494

478-
// TODO: This is a workaround. Remove this event do the callback right here when when this issue is fixed:
479-
// https://github.com/Leaflet/Leaflet/issues/4484
480-
newM.on('moveend', function() {
481-
var icon = L.divIcon({className: 'marker-icon'})
482-
newM.setIcon(icon);
483-
});
484-
485495
// now, create the polygon coordinate point for that marker
486496
var latlng = newM.getLatLng();
487497
var coords = this._poly._latlngs[0];

dist/leaflet.pm.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/js/L.PM.Edit.Poly.js

+17-7
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,26 @@ L.PM.Edit.Poly = L.Class.extend({
102102
rightM._middleMarkerLeft = middleMarker;
103103

104104
middleMarker.on('click', function() {
105+
106+
// TODO: move the next two lines inside _addMarker() as soon as
107+
// https://github.com/Leaflet/Leaflet/issues/4484
108+
// is fixed
109+
var icon = L.divIcon({className: 'marker-icon'});
110+
middleMarker.setIcon(icon);
111+
105112
self._addMarker(middleMarker, leftM, rightM);
106113
});
107114
middleMarker.on('movestart', function() {
115+
116+
// TODO: This is a workaround. Remove the moveend listener and callback as soon as this is fixed:
117+
// https://github.com/Leaflet/Leaflet/issues/4484
118+
middleMarker.on('moveend', function() {
119+
var icon = L.divIcon({className: 'marker-icon'});
120+
middleMarker.setIcon(icon);
121+
122+
middleMarker.off('moveend');
123+
});
124+
108125
self._addMarker(middleMarker, leftM, rightM);
109126
});
110127

@@ -118,13 +135,6 @@ L.PM.Edit.Poly = L.Class.extend({
118135
newM.off('movestart');
119136
newM.off('click');
120137

121-
// TODO: This is a workaround. Remove this event do the callback right here when when this issue is fixed:
122-
// https://github.com/Leaflet/Leaflet/issues/4484
123-
newM.on('moveend', function() {
124-
var icon = L.divIcon({className: 'marker-icon'})
125-
newM.setIcon(icon);
126-
});
127-
128138
// now, create the polygon coordinate point for that marker
129139
var latlng = newM.getLatLng();
130140
var coords = this._poly._latlngs[0];

0 commit comments

Comments
 (0)