giswqs commited on
Commit
1d689c9
1 Parent(s): 9a6cc23

Update app.py

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