def __init__(self, data, name=None, min_opacity=0.5, max_zoom=18, max_val=1.0, radius=25, blur=15, gradient=None, overlay=True, control=True, show=True, **kwargs): super(HeatMap, self).__init__(name=name, overlay=overlay, control=control, show=show) self._name = 'HeatMap' data = if_pandas_df_convert_to_numpy(data) self.data = [ [*validate_location(line[:2]), *line[2:]] # noqa: E999 for line in data ] if np.any(np.isnan(self.data)): raise ValueError('data may not contain NaNs.') self.options = parse_options(min_opacity=min_opacity, max_zoom=max_zoom, max=max_val, radius=radius, blur=blur, gradient=gradient, **kwargs)
def __init__(self, data, name=None, min_opacity=0.5, max_zoom=18, radius=25, blur=15, gradient=None, overlay=True, control=True, show=True, **kwargs): super(HeatMap, self).__init__(name=name, overlay=overlay, control=control, show=show) self._name = 'HeatMap' data = if_pandas_df_convert_to_numpy(data) self.data = [ [*validate_location(line[:2]), *line[2:]] # noqa: E999 for line in data ] if np.any(np.isnan(self.data)): raise ValueError('data may not contain NaNs.') if kwargs.pop('max_val', None): warnings.warn( 'The `max_val` parameter is no longer necessary. ' 'The largest intensity is calculated automatically.', stacklevel=2) self.options = parse_options(min_opacity=min_opacity, max_zoom=max_zoom, radius=radius, blur=blur, gradient=gradient, **kwargs)
def __init__(self, location=None, width='100%', height='100%', left='0%', top='0%', position='relative', tiles='OpenStreetMap', API_key=None, max_zoom=18, min_zoom=0, max_native_zoom=None, zoom_start=10, world_copy_jump=False, no_wrap=False, attr=None, min_lat=-90, max_lat=90, min_lon=-180, max_lon=180, max_bounds=False, detect_retina=False, crs='EPSG3857', control_scale=False, prefer_canvas=False, no_touch=False, disable_3d=False, subdomains='abc', png_enabled=False, zoom_control=True): super(Map, self).__init__() self._name = 'Map' self._env = ENV # Undocumented for now b/c this will be subject to a re-factor soon. self._png_image = None self.png_enabled = png_enabled if location is None: # If location is not passed we center and zoom out. self.location = [0, 0] self.zoom_start = 1 else: self.location = validate_location(location) self.zoom_start = zoom_start Figure().add_child(self) # Map Size Parameters. self.width = _parse_size(width) self.height = _parse_size(height) self.left = _parse_size(left) self.top = _parse_size(top) self.position = position self.min_lat = min_lat self.max_lat = max_lat self.min_lon = min_lon self.max_lon = max_lon self.max_bounds = max_bounds self.no_wrap = no_wrap self.world_copy_jump = world_copy_jump self.crs = crs self.control_scale = control_scale self.zoom_control = zoom_control self.global_switches = GlobalSwitches( prefer_canvas, no_touch, disable_3d ) self.objects_to_stay_in_front = [] if tiles: self.add_tile_layer( tiles=tiles, min_zoom=min_zoom, max_zoom=max_zoom, max_native_zoom=max_native_zoom, no_wrap=no_wrap, attr=attr, API_key=API_key, detect_retina=detect_retina, subdomains=subdomains )
def __init__(self, data, callback=None, options=None, name=None, overlay=True, control=True, show=True, **kwargs): if options is not None: kwargs.update(options) # options argument is legacy super(FastMarkerCluster, self).__init__(name=name, overlay=overlay, control=control, show=show, **kwargs) self._name = 'FastMarkerCluster' data = if_pandas_df_convert_to_numpy(data) self.data = [ [*validate_location(row[:2]), *row[2:]] # noqa: E999 for row in data ] if callback is None: self.callback = """ var callback = function (row) { var icon = L.AwesomeMarkers.icon(); var marker = L.marker(new L.LatLng(row[0], row[1])); marker.setIcon(icon); return marker; };""" else: self.callback = 'var callback = {};'.format(callback)
def __init__(self, location, radius=0, direction=0, arc=0, startAngle=0, stopAngle=0, **kwargs): super(SemiCircle, self).__init__(validate_location(location), **kwargs) self._name = 'SemiCircle' self.radius = radius self.direction = direction self.arc = arc self.startAngle = startAngle self.stopAngle = stopAngle self.kwargs = json.dumps(kwargs)
def __init__(self, location, popup=None, tooltip=None, icon=None, draggable=False, **kwargs): super(Marker, self).__init__() self._name = 'Marker' self.location = validate_location(location) self.options = parse_options( draggable=draggable or None, autoPan=draggable or None, **kwargs ) if icon is not None: self.add_child(icon) 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, data, name=None, min_opacity=0.5, max_zoom=18, max_val=1.0, radius=25, blur=15, gradient=None, overlay=True, control=True, show=True, **kwargs): super(HeatMap, self).__init__(name=name, overlay=overlay, control=control, show=show) self._name = 'HeatMap' data = if_pandas_df_convert_to_numpy(data) self.data = [[*validate_location(line[:2]), *line[2:]] # noqa: E999 for line in data] if np.any(np.isnan(self.data)): raise ValueError('data may not contain NaNs.') self.options = parse_options( min_opacity=min_opacity, max_zoom=max_zoom, max=max_val, radius=radius, blur=blur, gradient=gradient, **kwargs )
def __init__(self, location, popup=None, tooltip=None, icon=None, draggable=False, **kwargs): super(Marker, self).__init__() self._name = 'Marker' self.location = validate_location(location) self.options = parse_options(draggable=draggable or None, autoPan=draggable or None, **kwargs) if icon is not None: self.add_child(icon) 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, data, callback=None, options=None, name=None, overlay=True, control=True, show=True, icon_create_function=None, **kwargs): if options is not None: kwargs.update(options) # options argument is legacy super(FastMarkerCluster, self).__init__(name=name, overlay=overlay, control=control, show=show, icon_create_function=icon_create_function, **kwargs) self._name = 'FastMarkerCluster' data = if_pandas_df_convert_to_numpy(data) self.data = [[*validate_location(row[:2]), *row[2:]] # noqa: E999 for row in data] if callback is None: self.callback = """ var callback = function (row) { var icon = L.AwesomeMarkers.icon(); var marker = L.marker(new L.LatLng(row[0], row[1])); marker.setIcon(icon); return marker; };""" else: self.callback = 'var callback = {};'.format(callback)
def __init__( self, location=None, width='100%', height='100%', left='0%', top='0%', position='relative', tiles='OpenStreetMap', attr=None, min_zoom=0, max_zoom=18, zoom_start=10, min_lat=-90, max_lat=90, min_lon=-180, max_lon=180, max_bounds=False, crs='EPSG3857', control_scale=False, prefer_canvas=False, no_touch=False, disable_3d=False, png_enabled=False, zoom_control=True, **kwargs ): super(Map, self).__init__() self._name = 'Map' self._env = ENV # Undocumented for now b/c this will be subject to a re-factor soon. self._png_image = None self.png_enabled = png_enabled if location is None: # If location is not passed we center and zoom out. self.location = [0, 0] zoom_start = 1 else: self.location = validate_location(location) Figure().add_child(self) # Map Size Parameters. self.width = _parse_size(width) self.height = _parse_size(height) self.left = _parse_size(left) self.top = _parse_size(top) self.position = position max_bounds_array = [[min_lat, min_lon], [max_lat, max_lon]] \ if max_bounds else None self.crs = crs self.control_scale = control_scale self.options = parse_options( max_bounds=max_bounds_array, zoom=zoom_start, zoom_control=zoom_control, prefer_canvas=prefer_canvas, **kwargs ) self.global_switches = GlobalSwitches( no_touch, disable_3d ) self.objects_to_stay_in_front = [] if tiles: tile_layer = TileLayer(tiles=tiles, attr=attr, min_zoom=min_zoom, max_zoom=max_zoom) self.add_child(tile_layer, name=tile_layer.tile_name)
def test_validate_location_exceptions(location): """Test input that should raise an exception.""" with pytest.raises((TypeError, ValueError)): validate_location(location)
def test_validate_location(location): outcome = validate_location(location) assert outcome == [5., 3.]
def test_validate_location_exceptions(location): """Test input that should raise an exception.""" with pytest.raises((TypeError, ValueError)): validate_location(location)
def test_validate_location(location): outcome = validate_location(location) assert outcome == [5., 3.]
def __init__( self, location=None, width='100%', height='100%', left='0%', top='0%', position='relative', tiles='OpenStreetMap', attr=None, min_zoom=0, max_zoom=18, zoom_start=10, min_lat=-90, max_lat=90, min_lon=-180, max_lon=180, max_bounds=False, crs='EPSG3857', control_scale=False, prefer_canvas=False, no_touch=False, disable_3d=False, png_enabled=False, zoom_control=True, **kwargs ): super(Map, self).__init__() self._name = 'Map' self._env = ENV # Undocumented for now b/c this will be subject to a re-factor soon. self._png_image = None self.png_enabled = png_enabled if location is None: # If location is not passed we center and zoom out. self.location = [0, 0] zoom_start = 1 else: self.location = validate_location(location) Figure().add_child(self) # Map Size Parameters. self.width = _parse_size(width) self.height = _parse_size(height) self.left = _parse_size(left) self.top = _parse_size(top) self.position = position max_bounds_array = [[min_lat, min_lon], [max_lat, max_lon]] \ if max_bounds else None self.crs = crs self.control_scale = control_scale self.options = parse_options( max_bounds=max_bounds_array, zoom=zoom_start, zoom_control=zoom_control, prefer_canvas=prefer_canvas, **kwargs ) self.global_switches = GlobalSwitches( no_touch, disable_3d ) self.objects_to_stay_in_front = [] if tiles: tile_layer = TileLayer(tiles=tiles, attr=attr, min_zoom=min_zoom, max_zoom=max_zoom) self.add_child(tile_layer, name=tile_layer.tile_name)