giswqs commited on
Commit
7a0b996
1 Parent(s): 87caad2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -59
app.py CHANGED
@@ -1,59 +1,20 @@
1
- import ee
2
- import geemap
3
- from shiny import App, reactive, render, ui
4
- from shinywidgets import output_widget, render_widget
5
- from faicons import icon_svg
6
-
7
- geemap.ee_initialize(service_account=True)
8
-
9
- app_ui = ui.page_sidebar(
10
- ui.sidebar(
11
- ui.input_action_button(
12
- 'button',
13
- 'Generate map',
14
- icon = icon_svg('play')
15
- )
16
- ),
17
- ui.layout_column_wrap(
18
- output_widget('result')
19
- ),
20
- title = "Test geemap",
21
- fillable = True,
22
- )
23
-
24
-
25
- def server(input, output, session):
26
-
27
- @reactive.calc
28
- @reactive.event(input.button)
29
- def generate_map():
30
-
31
- Map = geemap.Map(center=[40, -100], zoom=4)
32
-
33
- landsat7 = (
34
- ee.Image('LANDSAT/LE7_TOA_5YEAR/1999_2003')
35
- .select(['B1', 'B2', 'B3', 'B4', 'B5', 'B7'])
36
- )
37
-
38
- landsat_vis = {'bands': ['B4', 'B3', 'B2'], 'gamma': 1.4}
39
-
40
- Map.addLayer(landsat7, landsat_vis, "Landsat")
41
-
42
- hyperion = ee.ImageCollection('EO1/HYPERION').filter(ee.Filter.date('2016-01-01', '2017-03-01'))
43
-
44
- hyperion_vis = {
45
- 'min': 1000.0,
46
- 'max': 14000.0,
47
- 'gamma': 2.5,
48
- }
49
- Map.addLayer(hyperion, hyperion_vis, 'Hyperion')
50
-
51
- return Map
52
-
53
- @output
54
- @render_widget
55
- def result():
56
- return generate_map()
57
-
58
-
59
- app = App(app_ui, server)
 
1
+ from shiny import reactive
2
+ from shiny.express import input, ui
3
+ from shinywidgets import render_widget
4
+ import ipyleaflet as ipyl
5
+
6
+ city_centers = {
7
+ "London": (51.5074, 0.1278),
8
+ "Paris": (48.8566, 2.3522),
9
+ "New York": (40.7128, -74.0060)
10
+ }
11
+
12
+ ui.input_select("center", "Center", choices=list(city_centers.keys()))
13
+
14
+ @render_widget
15
+ def map():
16
+ return ipyl.Map(zoom=4)
17
+
18
+ @reactive.effect
19
+ def _():
20
+ map.widget.center = city_centers[input.center()]