File size: 636 Bytes
a310dd9
 
 
 
af463aa
a310dd9
af463aa
a310dd9
 
 
 
 
af463aa
a310dd9
af463aa
 
a310dd9
 
 
 
 
af463aa
 
a310dd9
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import geopandas as gpd
from shiny import reactive
from shiny.express import input, ui
from shinywidgets import render_widget

from lonboard import Map, ScatterplotLayer

colors = {
    "Red": [200, 0, 0],
    "Green": [0, 200, 0],
    "Blue": [0, 0, 200],
}

ui.input_select("color_select", "Color", choices=list(colors.keys()))


@render_widget
def map():
    gdf = gpd.read_file(gpd.datasets.get_path("naturalearth_cities"))
    layer = ScatterplotLayer.from_geopandas(gdf, radius_min_pixels=2)
    return Map(layer)


@reactive.effect
def set_fill_color():
    map.widget.layers[0].get_fill_color = colors[input.color_select()]