Skip to content

Commit 0cdce5d

Browse files
committed
Remove map callbacks when DrawControl removed from map
1 parent b5b367b commit 0cdce5d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

js/src/controls/DrawControl.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,13 @@ export class LeafletDrawControlView extends control.LeafletControlView {
122122
this.model.on('change:data', this.data_to_layers.bind(this));
123123
}
124124

125+
remove() {
126+
this.map_view.obj.removeLayer(this.feature_group);
127+
this.map_view.obj.off('draw:created');
128+
this.map_view.obj.off('draw:edited');
129+
this.map_view.obj.off('draw:deleted');
130+
}
131+
125132
data_to_layers() {
126133
const data = this.model.get('data');
127134
this.feature_group.clearLayers();
@@ -181,5 +188,6 @@ export class LeafletDrawControlView extends control.LeafletControlView {
181188
}
182189
});
183190
}
191+
this.layers_to_data()
184192
}
185193
}

0 commit comments

Comments
 (0)