Skip to content

Commit

Permalink
Update add_subitem_model and remove_subitem_view using instanceof che…
Browse files Browse the repository at this point in the history
…cks.
  • Loading branch information
HaudinFlorence committed Sep 6, 2022
1 parent 36d6e74 commit e514e31
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions js/src/Map.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.

import { LeafletLayerModel } from './layers/Layer.js';

const widgets = require('@jupyter-widgets/base');
const L = require('./leaflet.js');
Expand Down Expand Up @@ -218,10 +219,10 @@ export class LeafletMapView extends utils.LeafletDOMWidgetView {
}

remove_subitem_view(child_view) {
if(child_view['name'].includes('Control')){
this.obj.removeControl(child_view.obj);
} else {
if(child_view instanceof(LeafletLayerView)){
this.obj.removeLayer(child_view.obj);
} else {
this.obj.removeControl(child_view.obj);
}
child_view.remove();
}
Expand All @@ -230,10 +231,10 @@ export class LeafletMapView extends utils.LeafletDOMWidgetView {
return this.create_child_view(child_model, {
map_view: this
}).then(view => {
if(child_model['name'].includes('Control')){
this.obj.addControl(view.obj);
} else {
if (child_model instanceof LeafletLayerModel) {
this.obj.addLayer(view.obj);
} else {
this.obj.addControl(view.obj);
}

// Trigger the displayed event of the child view.
Expand Down Expand Up @@ -281,6 +282,7 @@ export class LeafletMapView extends utils.LeafletDOMWidgetView {
var all_subitems = [];
layer_list.forEach((layer) => {
var subitem_list = layer.attributes.subitems;

subitem_list.forEach((subitem) => {
all_subitems.push(subitem);
});
Expand Down

0 comments on commit e514e31

Please sign in to comment.