def render(self, **kwargs): super(DualMap, self).render(**kwargs) for child, name, index in self.children_for_m2: if child._id in self.children_for_m2_copied: # This map has been rendered before, child was copied already. continue child_copy = deep_copy(child) if isinstance(child_copy, LayerControl): child_copy.reset() self.m2.add_child(child_copy, name, index) # m2 has already been rendered, so render the child here: child_copy.render() self.children_for_m2_copied.append(child._id)
def test_deep_copy(): m = Map() fg = FeatureGroup().add_to(m) Marker(location=(0, 0)).add_to(fg) m_copy = deep_copy(m) def check(item, item_copy): assert type(item) is type(item_copy) assert item._name == item_copy._name for attr in item.__dict__.keys(): if not attr.startswith('_'): assert getattr(item, attr) == getattr(item_copy, attr) assert item is not item_copy assert item._id != item_copy._id for child, child_copy in zip(item._children.values(), item_copy._children.values()): check(child, child_copy) check(m, m_copy)
def test_deep_copy(): m = Map() fg = FeatureGroup().add_to(m) Marker(location=(0, 0)).add_to(fg) m_copy = deep_copy(m) def check(item, item_copy): assert type(item) is type(item_copy) assert item._name == item_copy._name for attr in item.__dict__.keys(): if not attr.startswith('_'): assert getattr(item, attr) == getattr(item_copy, attr) assert item is not item_copy assert item._id != item_copy._id for child, child_copy in zip(item._children.values(), item_copy._children.values()): check(child, child_copy) check(m, m_copy)
def render(self, **kwargs): figure = self.get_root() assert isinstance(figure, Figure), ('You cannot render this Element ' 'if it is not in a Figure.') figure.header.add_child(JavascriptLink('https://rawcdn.githack.com/jieter/Leaflet.Sync/master/L.Map.Sync.js'), # noqa name='Leaflet.Sync') super(DualMap, self).render(**kwargs) for child, name, index in self.children_for_m2: if child._id in self.children_for_m2_copied: # This map has been rendered before, child was copied already. continue child_copy = deep_copy(child) if isinstance(child_copy, LayerControl): child_copy.reset() self.m2.add_child(child_copy, name, index) # m2 has already been rendered, so render the child here: child_copy.render() self.children_for_m2_copied.append(child._id)
def render(self, **kwargs): figure = self.get_root() assert isinstance(figure, Figure), ('You cannot render this Element ' 'if it is not in a Figure.') # Import Javascripts for name, url in _default_js: figure.header.add_child(JavascriptLink(url), name=name) super(DualMap, self).render(**kwargs) for child, name, index in self.children_for_m2: if child._id in self.children_for_m2_copied: # This map has been rendered before, child was copied already. continue child_copy = deep_copy(child) if isinstance(child_copy, LayerControl): child_copy.reset() self.m2.add_child(child_copy, name, index) # m2 has already been rendered, so render the child here: child_copy.render() self.children_for_m2_copied.append(child._id)
def render(self, **kwargs): figure = self.get_root() assert isinstance(figure, Figure), ('You cannot render this Element ' 'if it is not in a Figure.') figure.header.add_child( JavascriptLink( 'https://rawcdn.githack.com/jieter/Leaflet.Sync/master/L.Map.Sync.js' ), # noqa name='Leaflet.Sync') super(DualMap, self).render(**kwargs) for child, name, index in self.children_for_m2: if child._id in self.children_for_m2_copied: # This map has been rendered before, child was copied already. continue child_copy = deep_copy(child) self.m2.add_child(child_copy, name, index) # m2 has already been rendered, so render the child here: child_copy.render() self.children_for_m2_copied.append(child._id)