Py.Cafe

shiny-unofficial/

ipyleaflet

City Centers Interactive Map

DocsPricing
  • app.py
  • requirements.txt
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# original from https://shinylive.io/py/examples/#map
from shiny import reactive
from shiny.express import input, ui
from shinywidgets import render_widget
import ipyleaflet as ipyl

city_centers = {
    "London": (51.5074, 0.1278),
    "Paris": (48.8566, 2.3522),
    "New York": (40.7128, -74.0060),
}
ui.input_select("center", "Center", choices=list(city_centers.keys()))


@render_widget
def map():
    return ipyl.Map(zoom=4)


@reactive.effect
def _():
    map.widget.center = city_centers[input.center()]