def __init__(self, locations=None, popups=None, icons=None, name=None, overlay=True, control=True, show=True, icon_create_function=None, options=None, **kwargs): if options is not None: kwargs.update(options) # options argument is legacy super(MarkerCluster, self).__init__(name=name, overlay=overlay, control=control, show=show) self._name = 'MarkerCluster' if locations is not None: locations = validate_locations(locations) for i, location in enumerate(locations): self.add_child( Marker(location, popup=popups and popups[i], icon=icons and icons[i])) self.options = parse_options(**kwargs) if icon_create_function is not None: assert isinstance(icon_create_function, str) self.icon_create_function = icon_create_function
def __init__(self, locations, popup=None, tooltip=None): super(BaseMultiLocation, self).__init__() self.locations = validate_locations(locations) if popup is not None: self.add_child( popup if isinstance(popup, Popup) else Popup(str(popup))) if tooltip is not None: self.add_child(tooltip if isinstance(tooltip, Tooltip ) else Tooltip(str(tooltip)))
def __init__(self, locations, popup=None, tooltip=None): super(BaseMultiLocation, self).__init__() self.locations = validate_locations(locations) if popup is not None: self.add_child(popup if isinstance(popup, Popup) else Popup(str(popup))) if tooltip is not None: self.add_child(tooltip if isinstance(tooltip, Tooltip) else Tooltip(str(tooltip)))
def __init__(self, locations=None, popups=None, icons=None, name=None, overlay=True, control=True, show=True, icon_create_function=None, options=None, **kwargs): if options is not None: kwargs.update(options) # options argument is legacy super(MarkerCluster, self).__init__(name=name, overlay=overlay, control=control, show=show) self._name = 'MarkerCluster' if locations is not None: locations = validate_locations(locations) for i, location in enumerate(locations): self.add_child(Marker(location, popup=popups and popups[i], icon=icons and icons[i])) self.options = parse_options(**kwargs) if icon_create_function is not None: assert isinstance(icon_create_function, str) self.icon_create_function = icon_create_function
def test_validate_locations_exceptions(locations): """Test input that should raise an exception.""" with pytest.raises((TypeError, ValueError)): validate_locations(locations)
def test_validate_locations_multi(locations): outcome = validate_locations(locations) assert outcome == [[[0, 5], [1, 6], [2, 7]], [[3, 8], [4, 9]]]
def test_validate_locations(locations): outcome = validate_locations(locations) assert outcome == [[0., 5.], [1., 6.], [2., 7.]]