Skip to content

Commit 84aac77

Browse files
authored
Merge pull request #916 from descarteslabs/fix-draw-control
Remove map callbacks when DrawControl removed from map
2 parents c738402 + 7bc67ab commit 84aac77

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

js/src/controls/DrawControl.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,15 @@ 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+
this.model.off('msg:custom');
131+
this.model.off('change:data');
132+
}
133+
125134
data_to_layers() {
126135
const data = this.model.get('data');
127136
this.feature_group.clearLayers();
@@ -181,5 +190,6 @@ export class LeafletDrawControlView extends control.LeafletControlView {
181190
}
182191
});
183192
}
193+
this.layers_to_data()
184194
}
185195
}

0 commit comments

Comments
 (0)