Skip to content

Commit 18f361c

Browse files
authored
Merge pull request #146 from jyaistMap/jy-display-web-scene
Thanks @jyaistMap
2 parents c69102e + 5719e67 commit 18f361c

File tree

2 files changed

+211
-14
lines changed

2 files changed

+211
-14
lines changed

labs/display-web-map.ipynb renamed to labs/display_web_map.ipynb

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
},
1111
{
1212
"cell_type": "code",
13-
"execution_count": 1,
13+
"execution_count": 2,
1414
"metadata": {
1515
"collapsed": true
1616
},
@@ -30,25 +30,25 @@
3030
},
3131
{
3232
"cell_type": "code",
33-
"execution_count": 11,
33+
"execution_count": 3,
3434
"metadata": {},
3535
"outputs": [
3636
{
3737
"data": {
3838
"text/plain": [
3939
"[<Item title:\"Tree Canopy by City in Minnesota\" type:Web Map owner:vikalpa>,\n",
40-
" <Item title:\"Vaals6\" type:Web Map owner:haicao1975>,\n",
41-
" <Item title:\"San Diego Places To Go-复制\" type:Web Map owner:win_001>,\n",
42-
" <Item title:\"Location Map Telematica\" type:Web Map owner:roberto.arbanil>,\n",
4340
" <Item title:\"San Diego Shortlist-Copy\" type:Web Map owner:opsdashboarddemo>,\n",
4441
" <Item title:\"LA Parks and Trails Map (styled with popups)c\" type:Web Map owner:cheangerlove>,\n",
42+
" <Item title:\"Location Map Telematica\" type:Web Map owner:roberto.arbanil>,\n",
43+
" <Item title:\"Vaals6\" type:Web Map owner:haicao1975>,\n",
4544
" <Item title:\"ADFCA Short List Map Story\" type:Web Map owner:developer5>,\n",
45+
" <Item title:\"San Diego Places To Go-复制\" type:Web Map owner:win_001>,\n",
4646
" <Item title:\"San Diego Places To Go-Copy\" type:Web Map owner:hayam_osama>,\n",
4747
" <Item title:\"Vaals9\" type:Web Map owner:haicao1975>,\n",
4848
" <Item title:\"San Diego Shortlist-Copia\" type:Web Map owner:paoloprova>]"
4949
]
5050
},
51-
"execution_count": 11,
51+
"execution_count": 3,
5252
"metadata": {},
5353
"output_type": "execute_result"
5454
}
@@ -67,7 +67,7 @@
6767
},
6868
{
6969
"cell_type": "code",
70-
"execution_count": 12,
70+
"execution_count": 8,
7171
"metadata": {},
7272
"outputs": [
7373
{
@@ -94,25 +94,32 @@
9494
"<Item title:\"LA Parks and Trails Map (styled with popups)c\" type:Web Map owner:cheangerlove>"
9595
]
9696
},
97-
"execution_count": 12,
97+
"execution_count": 8,
9898
"metadata": {},
9999
"output_type": "execute_result"
100100
}
101101
],
102102
"source": [
103-
"webmap = webmaps[5]\n",
103+
"webmap = webmaps[2]\n",
104104
"webmap"
105105
]
106106
},
107+
{
108+
"cell_type": "markdown",
109+
"metadata": {},
110+
"source": [
111+
"## To display a web scene in your notebook, query the `WebMap` object."
112+
]
113+
},
107114
{
108115
"cell_type": "code",
109-
"execution_count": 6,
116+
"execution_count": 9,
110117
"metadata": {},
111118
"outputs": [
112119
{
113120
"data": {
114121
"application/vnd.jupyter.widget-view+json": {
115-
"model_id": "c90306bdb16442178b019338eec3fb33"
122+
"model_id": "8310f2d7aa1d4625bbe84835deb8b745"
116123
}
117124
},
118125
"metadata": {},
@@ -125,9 +132,16 @@
125132
"la_parks_trails"
126133
]
127134
},
135+
{
136+
"cell_type": "markdown",
137+
"metadata": {},
138+
"source": [
139+
"## Challenge"
140+
]
141+
},
128142
{
129143
"cell_type": "code",
130-
"execution_count": 7,
144+
"execution_count": 10,
131145
"metadata": {},
132146
"outputs": [
133147
{
@@ -145,7 +159,7 @@
145159
},
146160
{
147161
"cell_type": "code",
148-
"execution_count": 8,
162+
"execution_count": 12,
149163
"metadata": {},
150164
"outputs": [
151165
{
@@ -162,7 +176,7 @@
162176
}
163177
],
164178
"source": [
165-
"for lyr in la_prk_trails_webmap['operationalLayers']:\n",
179+
"for lyr in la_parks_trails['operationalLayers']:\n",
166180
" print(\"{}\\n\\t{}\".format(lyr['id'], lyr['url']))"
167181
]
168182
}

labs/display_web_scene.ipynb

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Display a Web Scene ArcGIS DevLab\n",
8+
"\n",
9+
"This is the completed solution for the [Diplay a web scene](https://developers.arcgis.com/labs/develop/python/display-a-web-scene) ArcGIS DevLab. [ArcGIS DevLabs](https://developers.arcgis.com/labs) are short introductory tutorials to guide you through the three phases of building geospatial apps: Data, Design, Develop."
10+
]
11+
},
12+
{
13+
"cell_type": "code",
14+
"execution_count": 2,
15+
"metadata": {},
16+
"outputs": [
17+
{
18+
"name": "stdout",
19+
"output_type": "stream",
20+
"text": [
21+
"Connected to ArcGIS Online\n"
22+
]
23+
}
24+
],
25+
"source": [
26+
"from arcgis.gis import GIS\n",
27+
"dev_gis = GIS(\"https://www.arcgis.com\")\n",
28+
"print(\"Connected to {}\".format(dev_gis.properties.portalName))"
29+
]
30+
},
31+
{
32+
"cell_type": "code",
33+
"execution_count": 3,
34+
"metadata": {},
35+
"outputs": [
36+
{
37+
"data": {
38+
"text/plain": [
39+
"[<Item title:\"LA Trails and Trailheads\" type:Web Scene owner:esri_devlabs>,\n",
40+
" <Item title:\"3d trails and trailheads LA\" type:Web Scene owner:tim.lohnes_Hayward>]"
41+
]
42+
},
43+
"execution_count": 3,
44+
"metadata": {},
45+
"output_type": "execute_result"
46+
}
47+
],
48+
"source": [
49+
"webscene_search = dev_gis.content.search(query=\"LA Trails *\", item_type=\"Web Scene\")\n",
50+
"webscene_search"
51+
]
52+
},
53+
{
54+
"cell_type": "code",
55+
"execution_count": 4,
56+
"metadata": {},
57+
"outputs": [
58+
{
59+
"data": {
60+
"text/html": [
61+
"<div class=\"item_container\" style=\"height: auto; overflow: hidden; border: 1px solid #cfcfcf; border-radius: 2px; background: #f6fafa; line-height: 1.21429em; padding: 10px;\">\n",
62+
" <div class=\"item_left\" style=\"width: 210px; float: left;\">\n",
63+
" <a href='https://www.arcgis.com/home/item.html?id=1da0ba4b0f674286875e58ec397260f1' target='_blank'>\n",
64+
" <img src='https://www.arcgis.com/sharing/rest//content/items/1da0ba4b0f674286875e58ec397260f1/info/thumbnail/thumbnail.jpeg' class=\"itemThumbnail\">\n",
65+
" </a>\n",
66+
" </div>\n",
67+
"\n",
68+
" <div class=\"item_right\" style=\"float: none; width: auto; overflow: hidden;\">\n",
69+
" <a href='https://www.arcgis.com/home/item.html?id=1da0ba4b0f674286875e58ec397260f1' target='_blank'><b>LA Trails and Trailheads</b>\n",
70+
" </a>\n",
71+
" <br/><img src='https://www.arcgis.com/home/js/jsapi/esri/css/images/item_type_icons/websceneglobal16.png' style=\"vertical-align:middle;\">Web Scene by esri_devlabs\n",
72+
" <br/>Last Modified: September 28, 2017\n",
73+
" <br/>0 comments, 238 views\n",
74+
" </div>\n",
75+
" </div>\n",
76+
" "
77+
],
78+
"text/plain": [
79+
"<Item title:\"LA Trails and Trailheads\" type:Web Scene owner:esri_devlabs>"
80+
]
81+
},
82+
"execution_count": 4,
83+
"metadata": {},
84+
"output_type": "execute_result"
85+
}
86+
],
87+
"source": [
88+
"webscene_item = webscene_search[0]\n",
89+
"webscene_item"
90+
]
91+
},
92+
{
93+
"cell_type": "markdown",
94+
"metadata": {},
95+
"source": [
96+
"## To display a web scene in your notebook, query the `WebScene` object."
97+
]
98+
},
99+
{
100+
"cell_type": "code",
101+
"execution_count": null,
102+
"metadata": {
103+
"collapsed": true
104+
},
105+
"outputs": [],
106+
"source": [
107+
"from arcgis.mapping import WebScene\n",
108+
"la_trails = WebScene(webscene_item)\n",
109+
"la_trails"
110+
]
111+
},
112+
{
113+
"cell_type": "markdown",
114+
"metadata": {},
115+
"source": [
116+
"## Challenge"
117+
]
118+
},
119+
{
120+
"cell_type": "code",
121+
"execution_count": 6,
122+
"metadata": {
123+
"scrolled": true
124+
},
125+
"outputs": [
126+
{
127+
"name": "stdout",
128+
"output_type": "stream",
129+
"text": [
130+
"The web scene has 2 layers\n"
131+
]
132+
}
133+
],
134+
"source": [
135+
"op_layers = la_trails['operationalLayers']\n",
136+
"print(\"The web scene has {} layers\".format(len(op_layers)))"
137+
]
138+
},
139+
{
140+
"cell_type": "code",
141+
"execution_count": 7,
142+
"metadata": {},
143+
"outputs": [
144+
{
145+
"name": "stdout",
146+
"output_type": "stream",
147+
"text": [
148+
"Trailheads - Trailheads\n",
149+
"\thttps://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads/FeatureServer/0\n",
150+
"Trails - Trails 0\n",
151+
"\thttps://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trails/FeatureServer/0\n"
152+
]
153+
}
154+
],
155+
"source": [
156+
"for lyr in op_layers:\n",
157+
" print(\"{}\\n\\t{}\".format(lyr['title'], lyr['url']))"
158+
]
159+
}
160+
],
161+
"metadata": {
162+
"anaconda-cloud": {},
163+
"kernelspec": {
164+
"display_name": "Python [conda env:arcgis-pyapi]",
165+
"language": "python",
166+
"name": "conda-env-arcgis-pyapi-py"
167+
},
168+
"language_info": {
169+
"codemirror_mode": {
170+
"name": "ipython",
171+
"version": 3
172+
},
173+
"file_extension": ".py",
174+
"mimetype": "text/x-python",
175+
"name": "python",
176+
"nbconvert_exporter": "python",
177+
"pygments_lexer": "ipython3",
178+
"version": "3.5.3"
179+
}
180+
},
181+
"nbformat": 4,
182+
"nbformat_minor": 2
183+
}

0 commit comments

Comments
 (0)