giswqs commited on
Commit
4beba33
1 Parent(s): 72b805d

Added center aligned page

Browse files
pages/00_home.py CHANGED
@@ -1,25 +1,26 @@
1
  import solara
2
 
 
3
  @solara.component
4
  def Page():
 
 
 
 
 
5
 
6
- markdown = """
7
- ## Solara for Geospatial Applications
8
-
9
- ### Introduction
10
-
11
- **A collection of [Solara](https://github.com/widgetti/solara) web apps for geospatial applications.**
12
 
13
- Just a proof-of-concept for now. Not all features are working yet. More features will be added in the future. Click on the menu above to see the other pages.
14
 
15
- - Web App: <https://giswqs-solara-geospatial.hf.space>
16
- - GitHub: <https://github.com/opengeos/solara-geospatial>
17
- - Hugging Face: <https://huggingface.co/spaces/giswqs/solara-geospatial>
18
 
19
- ### Demos
20
 
21
- ![](https://i.imgur.com/4uIEnAJ.gif)
22
 
23
- """
24
 
25
- solara.Markdown(markdown)
 
1
  import solara
2
 
3
+
4
  @solara.component
5
  def Page():
6
+ with solara.Column(align="center"):
7
+ markdown = """
8
+ ## Solara for Geospatial Applications
9
+
10
+ ### Introduction
11
 
12
+ **A collection of [Solara](https://github.com/widgetti/solara) web apps for geospatial applications.**
 
 
 
 
 
13
 
14
+ Just a proof-of-concept for now. Not all features are working yet. More features will be added in the future. Click on the menu above to see the other pages.
15
 
16
+ - Web App: <https://giswqs-solara-geospatial.hf.space>
17
+ - GitHub: <https://github.com/opengeos/solara-geospatial>
18
+ - Hugging Face: <https://huggingface.co/spaces/giswqs/solara-geospatial>
19
 
20
+ ### Demos
21
 
22
+ ![](https://i.imgur.com/4uIEnAJ.gif)
23
 
24
+ """
25
 
26
+ solara.Markdown(markdown)
pages/01_leafmap.py CHANGED
@@ -12,7 +12,7 @@ class Map(leafmap.Map):
12
  # Add what you want below
13
  self.add_basemap("OpenTopoMap")
14
  change_basemap(self)
15
-
16
 
17
  @solara.component
18
  def Page():
@@ -29,7 +29,6 @@ def Page():
29
  scroll_wheel_zoom=True,
30
  toolbar_ctrl=False,
31
  data_ctrl=False,
32
-
33
  )
34
  solara.Text(f"Zoom: {zoom.value}")
35
  solara.Text(f"Center: {center.value}")
 
12
  # Add what you want below
13
  self.add_basemap("OpenTopoMap")
14
  change_basemap(self)
15
+
16
 
17
  @solara.component
18
  def Page():
 
29
  scroll_wheel_zoom=True,
30
  toolbar_ctrl=False,
31
  data_ctrl=False,
 
32
  )
33
  solara.Text(f"Zoom: {zoom.value}")
34
  solara.Text(f"Center: {center.value}")
pages/02_geemap.py CHANGED
@@ -1,4 +1,3 @@
1
-
2
  import ee
3
  import geemap
4
 
@@ -14,10 +13,8 @@ class Map(geemap.Map):
14
  self.add_ee_data()
15
  self.add_layer_manager()
16
  self.add_inspector()
17
-
18
 
19
  def add_ee_data(self):
20
-
21
  # Add Earth Engine dataset
22
  dem = ee.Image('USGS/SRTMGL1_003')
23
  landsat7 = ee.Image('LANDSAT/LE7_TOA_5YEAR/1999_2003').select(
@@ -37,7 +34,8 @@ class Map(geemap.Map):
37
  self.addLayer(
38
  landsat7,
39
  {'bands': ['B4', 'B3', 'B2'], 'min': 20, 'max': 200, 'gamma': 2.0},
40
- 'Landsat 7', False
 
41
  )
42
  self.addLayer(states, {}, "US States")
43
 
@@ -56,8 +54,7 @@ def Page():
56
  on_center=center.set,
57
  scroll_wheel_zoom=True,
58
  add_google_map=True,
59
- height="700px"
60
-
61
  )
62
  solara.Text(f"Zoom: {zoom.value}")
63
  solara.Text(f"Center: {center.value}")
 
 
1
  import ee
2
  import geemap
3
 
 
13
  self.add_ee_data()
14
  self.add_layer_manager()
15
  self.add_inspector()
 
16
 
17
  def add_ee_data(self):
 
18
  # Add Earth Engine dataset
19
  dem = ee.Image('USGS/SRTMGL1_003')
20
  landsat7 = ee.Image('LANDSAT/LE7_TOA_5YEAR/1999_2003').select(
 
34
  self.addLayer(
35
  landsat7,
36
  {'bands': ['B4', 'B3', 'B2'], 'min': 20, 'max': 200, 'gamma': 2.0},
37
+ 'Landsat 7',
38
+ False,
39
  )
40
  self.addLayer(states, {}, "US States")
41
 
 
54
  on_center=center.set,
55
  scroll_wheel_zoom=True,
56
  add_google_map=True,
57
+ height="700px",
 
58
  )
59
  solara.Text(f"Zoom: {zoom.value}")
60
  solara.Text(f"Center: {center.value}")
pages/03_mapbox.py CHANGED
@@ -1,4 +1,3 @@
1
-
2
  import mapwidget.mapbox as mapwidget
3
 
4
  import solara
@@ -10,16 +9,15 @@ center = solara.reactive((20, 0))
10
  @solara.component
11
  def Page():
12
  with solara.Column(style={"min-width": "500px", "height": "500px"}):
13
- solara.Text("Not fully working yet. Try resizing the window to use the full width.")
 
 
14
  # solara components support reactive variables
15
  solara.SliderInt(label="Zoom level", value=zoom, min=1, max=20)
16
  # using 3rd party widget library require wiring up the events manually
17
  # using zoom.value and zoom.set
18
  mapwidget.Map.element( # type: ignore
19
- zoom=zoom.value,
20
- center=center.value,
21
- height='600px',
22
- width="100%"
23
  )
24
  solara.Text(f"Zoom: {zoom.value}")
25
  solara.Text(f"Center: {center.value}")
 
 
1
  import mapwidget.mapbox as mapwidget
2
 
3
  import solara
 
9
  @solara.component
10
  def Page():
11
  with solara.Column(style={"min-width": "500px", "height": "500px"}):
12
+ solara.Text(
13
+ "Not fully working yet. Try resizing the window to use the full width."
14
+ )
15
  # solara components support reactive variables
16
  solara.SliderInt(label="Zoom level", value=zoom, min=1, max=20)
17
  # using 3rd party widget library require wiring up the events manually
18
  # using zoom.value and zoom.set
19
  mapwidget.Map.element( # type: ignore
20
+ zoom=zoom.value, center=center.value, height='600px', width="100%"
 
 
 
21
  )
22
  solara.Text(f"Zoom: {zoom.value}")
23
  solara.Text(f"Center: {center.value}")
pages/04_cesium.py CHANGED
@@ -1,4 +1,3 @@
1
-
2
  import os
3
  import mapwidget.cesium as mapwidget
4
 
@@ -12,6 +11,7 @@ if os.environ.get('CESIUM_TOKEN') is None:
12
  else:
13
  token = os.environ.get('CESIUM_TOKEN')
14
 
 
15
  @solara.component
16
  def Page():
17
  with solara.Column(style={"min-width": "500px", "height": "500px"}):
@@ -20,9 +20,5 @@ def Page():
20
  # using 3rd party widget library require wiring up the events manually
21
  # using zoom.value and zoom.set
22
  mapwidget.Map.element( # type: ignore
23
- center=center.value,
24
- altitude=altitude.value,
25
- height='600px',
26
- width="100%"
27
  )
28
-
 
 
1
  import os
2
  import mapwidget.cesium as mapwidget
3
 
 
11
  else:
12
  token = os.environ.get('CESIUM_TOKEN')
13
 
14
+
15
  @solara.component
16
  def Page():
17
  with solara.Column(style={"min-width": "500px", "height": "500px"}):
 
20
  # using 3rd party widget library require wiring up the events manually
21
  # using zoom.value and zoom.set
22
  mapwidget.Map.element( # type: ignore
23
+ center=center.value, altitude=altitude.value, height='600px', width="100%"
 
 
 
24
  )
 
pages/05_maplibre.py CHANGED
@@ -1,4 +1,3 @@
1
-
2
  import mapwidget.maplibre as mapwidget
3
 
4
  import solara
@@ -10,17 +9,16 @@ center = solara.reactive((20, 0))
10
  @solara.component
11
  def Page():
12
  with solara.Column(style={"min-width": "500px", "height": "500px"}):
13
- solara.Text("Not fully working yet. Try resizing the window to use the full width.")
 
 
14
 
15
  # solara components support reactive variables
16
  solara.SliderInt(label="Zoom level", value=zoom, min=1, max=20)
17
  # using 3rd party widget library require wiring up the events manually
18
  # using zoom.value and zoom.set
19
  mapwidget.Map.element( # type: ignore
20
- zoom=zoom.value,
21
- center=center.value,
22
- height='600px',
23
- width="100%"
24
  )
25
  solara.Text(f"Zoom: {zoom.value}")
26
  solara.Text(f"Center: {center.value}")
 
 
1
  import mapwidget.maplibre as mapwidget
2
 
3
  import solara
 
9
  @solara.component
10
  def Page():
11
  with solara.Column(style={"min-width": "500px", "height": "500px"}):
12
+ solara.Text(
13
+ "Not fully working yet. Try resizing the window to use the full width."
14
+ )
15
 
16
  # solara components support reactive variables
17
  solara.SliderInt(label="Zoom level", value=zoom, min=1, max=20)
18
  # using 3rd party widget library require wiring up the events manually
19
  # using zoom.value and zoom.set
20
  mapwidget.Map.element( # type: ignore
21
+ zoom=zoom.value, center=center.value, height='600px', width="100%"
 
 
 
22
  )
23
  solara.Text(f"Zoom: {zoom.value}")
24
  solara.Text(f"Center: {center.value}")
pages/06_openlayers.py CHANGED
@@ -1,4 +1,3 @@
1
-
2
  import mapwidget.openlayers as mapwidget
3
 
4
  import solara
@@ -15,10 +14,7 @@ def Page():
15
  # using 3rd party widget library require wiring up the events manually
16
  # using zoom.value and zoom.set
17
  mapwidget.Map.element( # type: ignore
18
- zoom=zoom.value,
19
- center=center.value,
20
- height='600px',
21
- width="100%"
22
  )
23
  # solara.Text(f"Zoom: {zoom.value}")
24
  # solara.Text(f"Center: {center.value}")
 
 
1
  import mapwidget.openlayers as mapwidget
2
 
3
  import solara
 
14
  # using 3rd party widget library require wiring up the events manually
15
  # using zoom.value and zoom.set
16
  mapwidget.Map.element( # type: ignore
17
+ zoom=zoom.value, center=center.value, height='600px', width="100%"
 
 
 
18
  )
19
  # solara.Text(f"Zoom: {zoom.value}")
20
  # solara.Text(f"Center: {center.value}")
pages/07_ipyleaflet.py CHANGED
@@ -13,16 +13,16 @@ class Map(ipyleaflet.Map):
13
  # Add what you want below
14
 
15
  label = widgets.Label('Clicked location')
16
- output = widgets.Output()
17
- widget = widgets.VBox([label, output])
18
  control = ipyleaflet.WidgetControl(widget=widget, position='bottomright')
19
  self.add_control(control)
20
-
21
  def handle_interaction(**kwargs):
22
  latlon = kwargs.get("coordinates")
23
  if kwargs.get("type") == "click":
 
 
24
  with output:
25
- output.clear_output()
26
  print(latlon)
27
 
28
  self.on_interaction(handle_interaction)
@@ -38,7 +38,6 @@ def Page():
38
  center=center.value,
39
  on_center=center.set,
40
  scroll_wheel_zoom=True,
41
-
42
  )
43
  solara.Text(f"Zoom: {zoom.value}")
44
  solara.Text(f"Center: {center.value}")
 
13
  # Add what you want below
14
 
15
  label = widgets.Label('Clicked location')
16
+ widget = widgets.VBox([label])
 
17
  control = ipyleaflet.WidgetControl(widget=widget, position='bottomright')
18
  self.add_control(control)
19
+
20
  def handle_interaction(**kwargs):
21
  latlon = kwargs.get("coordinates")
22
  if kwargs.get("type") == "click":
23
+ output = widgets.Output()
24
+ widget.children = [label, output]
25
  with output:
 
26
  print(latlon)
27
 
28
  self.on_interaction(handle_interaction)
 
38
  center=center.value,
39
  on_center=center.set,
40
  scroll_wheel_zoom=True,
 
41
  )
42
  solara.Text(f"Zoom: {zoom.value}")
43
  solara.Text(f"Center: {center.value}")