shyft.dashboard.maps.map_viewer
Classes
|
Backend for plots of Maps with custom layers |
- class shyft.dashboard.maps.map_viewer.MapViewer(*, base_map: BaseMap, width: int = 300, height: int = 300, extent_padding: float = 0)
Bases:
object
Backend for plots of Maps with custom layers
Examples
from statkraft.bokeh.maps.map_viewer import MapViewerfrom statkraft.bokeh.maps.layer_data import LayerDataHandlefrom statkraft.bokeh.maps.map_layer import MapLayerfrom statkraft.bokeh.test.maps.test_map_fixtures import basemap_factory# initialisationbase_map = basemap_factory()# create map viewermap_viewer = MapViewer(width=300, height=300, base_map=base_map, extent_padding=10)# add layerlayer1 = MapLayer(map_viewer=map_viewer, name=’first layer’, layer_type=LayerType.POINT,glyph_fixed_kwargs={‘radius’: 5},glyph_variable_kwargs={‘x’: ‘x’, ‘y’: ‘y’},)# update the data with layer_data_handlemin_x = 26621 + 22373*0.5 + 50min_y = 6599653 + 18731*0.5 + 50max_x = 26621 + 22373*0.5 + 100max_y = 6599653 + 18731*0.5 + 100updated_data = {‘x’: [min_x, max_x],‘y’: [min_y, max_y]}layer_data_handle = LayerDataHandle(map_layer=layer1, data=updated_data)map_viewer.receive_layer_data_handles([layer_data_handle])- __init__(*, base_map: BaseMap, width: int = 300, height: int = 300, extent_padding: float = 0) None
MapViewer Backend for plots of Maps with custom layers
- Parameters:
base_map – BaseMap instance to use in the back ground
width – with of the figure
height – height of the figure
extent_padding – extra padding for the axis, when snapping to all objects in layers
- add_layer(map_layer: MapLayer) Tuple[Renderer, HoverTool]
Function to add a new layer to the Map This is called from the Layer constructor
- update_axes() None
This function updates the figure axis based on layer bbox