giswqs pre-commit-ci[bot] commited on
Commit
5586dbd
·
unverified ·
1 Parent(s): b7053a7

Add dashboard example (#3)

Browse files

* Add dashboard example

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

Files changed (1) hide show
  1. notebooks/dashboard.ipynb +119 -0
notebooks/dashboard.ipynb ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "id": "0",
7
+ "metadata": {},
8
+ "outputs": [],
9
+ "source": [
10
+ "# %pip install leafmap"
11
+ ]
12
+ },
13
+ {
14
+ "cell_type": "code",
15
+ "execution_count": null,
16
+ "id": "1",
17
+ "metadata": {},
18
+ "outputs": [],
19
+ "source": [
20
+ "import leafmap.maplibregl as leafmap\n",
21
+ "import ipywidgets as widgets"
22
+ ]
23
+ },
24
+ {
25
+ "cell_type": "code",
26
+ "execution_count": null,
27
+ "id": "2",
28
+ "metadata": {},
29
+ "outputs": [],
30
+ "source": [
31
+ "tw = leafmap.TabWidget(\n",
32
+ " title=\"Interactive Dashboard\",\n",
33
+ " tabs=(\"Home\", \"Map\", \"Population\", \"Settings\"),\n",
34
+ " icons=(\"mdi-home\", \"mdi-airplane\", \"mdi-account-box\", \"mdi-cog\"),\n",
35
+ " show_panel_titles=False,\n",
36
+ ")\n",
37
+ "\n",
38
+ "# Customize dialog\n",
39
+ "tw.set_help_title(\"About this dashboard\")\n",
40
+ "tw.set_help_content(\n",
41
+ " widgets.HTML(\n",
42
+ " \"\"\"\n",
43
+ " <p><b>User Guide</b></p>\n",
44
+ " <ul>\n",
45
+ " <li>Step 1: Click on the tab</li>\n",
46
+ " <li>Navigate the map</li>\n",
47
+ " <li>? — help</li>\n",
48
+ " </ul>\n",
49
+ " \"\"\"\n",
50
+ " )\n",
51
+ ")\n",
52
+ "\n",
53
+ "m = leafmap.Map(projection=\"globe\", sidebar_visible=True, height=\"600px\")\n",
54
+ "m.add_overture_3d_buildings()\n",
55
+ "m.create_container()\n",
56
+ "\n",
57
+ "home_tab = widgets.HTML(\n",
58
+ " \"\"\"\n",
59
+ " <h1>Welcome to the Leafmap Visualization Dashboard</h1>\n",
60
+ " <p>This is the home tab.</p>\n",
61
+ " <img src=\"https://assets.gishub.org/images/geog-312.png\" width=\"100%\">\n",
62
+ " \"\"\"\n",
63
+ ")\n",
64
+ "\n",
65
+ "settings_tab = widgets.HTML(\n",
66
+ " \"\"\"\n",
67
+ " <h1>Settings</h1>\n",
68
+ " <p>This is the settings tab.</p>\n",
69
+ " \"\"\"\n",
70
+ ")\n",
71
+ "\n",
72
+ "data = \"https://github.com/opengeos/datasets/releases/download/vector/countries.geojson\"\n",
73
+ "\n",
74
+ "m2 = leafmap.Map(style=\"liberty\", projection=\"globe\")\n",
75
+ "first_symbol_id = m2.find_first_symbol_layer()[\"id\"]\n",
76
+ "m2.add_data(\n",
77
+ " data,\n",
78
+ " column=\"POP_EST\",\n",
79
+ " scheme=\"Quantiles\",\n",
80
+ " cmap=\"Blues\",\n",
81
+ " legend_title=\"Population\",\n",
82
+ " name=\"population\",\n",
83
+ " # before_id=first_symbol_id,\n",
84
+ " extrude=True,\n",
85
+ " scale_factor=1000,\n",
86
+ ")\n",
87
+ "container = m2.create_container()\n",
88
+ "\n",
89
+ "tw.set_tab_content(0, home_tab)\n",
90
+ "tw.set_tab_content(1, m.container)\n",
91
+ "tw.set_tab_content(3, settings_tab)\n",
92
+ "tw.set_tab_content(2, m2.container)\n",
93
+ "\n",
94
+ "tw.widget"
95
+ ]
96
+ }
97
+ ],
98
+ "metadata": {
99
+ "kernelspec": {
100
+ "display_name": "geo",
101
+ "language": "python",
102
+ "name": "python3"
103
+ },
104
+ "language_info": {
105
+ "codemirror_mode": {
106
+ "name": "ipython",
107
+ "version": 3
108
+ },
109
+ "file_extension": ".py",
110
+ "mimetype": "text/x-python",
111
+ "name": "python",
112
+ "nbconvert_exporter": "python",
113
+ "pygments_lexer": "ipython3",
114
+ "version": "3.12.2"
115
+ }
116
+ },
117
+ "nbformat": 4,
118
+ "nbformat_minor": 5
119
+ }