Skip to content

Commit e0482e6

Browse files
authored
Update layer access for MapContent
Update references of WebMap to Map and WebScene to Scene
2 parents 9a0d611 + cd4bf04 commit e0482e6

8 files changed

Lines changed: 1214 additions & 474 deletions

File tree

guide/03-the-gis/cloning-content.ipynb

Lines changed: 1124 additions & 393 deletions
Large diffs are not rendered by default.

guide/09-finding-places-with-geocoding/part1_what_is_geocoding.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1122,7 +1122,7 @@
11221122
"source": [
11231123
"### Geocoding coverage\n",
11241124
"\n",
1125-
"For countries covered by a geocoding service, e.g. the ArcGIS World Geocoding Service, the address coverage, the supported language, and relative geocoding quality would vary. The `Geocoding Service Coverage` WebMap object displayed below illustrates the various levels.\n",
1125+
"For countries covered by a geocoding service, e.g. the ArcGIS World Geocoding Service, the address coverage, the supported language, and relative geocoding quality would vary. The `Geocoding Service Coverage` Map object displayed below illustrates the various levels.\n",
11261126
"\n",
11271127
"The overall geocoding quality is a function of the degree of street-level address coverage in a country, knowledge of a country's address styles, and geocoding performance for addresses in that country. The quality levels are subject to change. Typically, the quality of geocoding for a given country improves over time and may be upgraded to a better level, but there may be instances where countries are downgraded to a lower level based on user feedback.\n",
11281128
"\n",

guide/10-mapping-and-visualization/working-with-web-maps-and-web-scenes.ipynb

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,15 @@
2424
"Web maps and scenes are stored as items on your portal and their content is in JavaScript Object Notation (JSON), a text format that can easily be transferred, stored, and edited. In this guide we will observe how to work maps and scenes using the `arcgis.layers` module.\n",
2525
"\n",
2626
"## Working with web maps\n",
27-
"2D maps in your GIS are stored as web map items. A web map contains a JSON defining the bookmarks, layers, their symbology, order and other cartographic information. If you are interested in learning more about this specification, refer to this [documentation](/web-map-specification/). In the `mapping` module, web maps are represented using a `WebMap` class. At version 1.3 of the Python API, the `WebMap` class has been enhanced with the ability to easily add, remove layers and a few other basic operations."
27+
"2D maps in your GIS are stored as web map items. A web map contains a JSON defining the bookmarks, layers, their symbology, order and other cartographic information. If you are interested in learning more about this specification, refer to this [documentation](/web-map-specification/). In the `map` module, web maps are represented using a `Map` class. At version 2.4 of the Python API, the `Map` class has been enhanced with the ability to easily add, remove layers and a few other basic operations."
2828
]
2929
},
3030
{
3131
"cell_type": "code",
32-
"execution_count": 1,
32+
"execution_count": null,
3333
"metadata": {},
3434
"outputs": [],
3535
"source": [
36-
"from IPython.display import display\n",
37-
"import arcgis\n",
3836
"from arcgis.gis import GIS\n",
3937
"\n",
4038
"# connect to your GIS\n",
@@ -121,7 +119,7 @@
121119
"metadata": {},
122120
"source": [
123121
"### Creating a `Map` object\n",
124-
"You can create an empty web map with a default basemap and no operational by initializing the `Map` class with no arguments:"
122+
"You can create an empty web map with a default basemap and no operational layers by initializing the `Map` class with no arguments:"
125123
]
126124
},
127125
{
@@ -220,7 +218,7 @@
220218
"cell_type": "markdown",
221219
"metadata": {},
222220
"source": [
223-
"You can also create a `WebMap` object from an existing web map item by passing the web map item as the parameter to the constructor:"
221+
"You can also create a `Map` object from an existing web map item by passing the web map item as the parameter to the constructor:"
224222
]
225223
},
226224
{
@@ -835,7 +833,7 @@
835833
"name": "python",
836834
"nbconvert_exporter": "python",
837835
"pygments_lexer": "ipython3",
838-
"version": "3.11.0"
836+
"version": "3.13.5"
839837
},
840838
"toc": {
841839
"base_numbering": 1,

labs/display_web_map.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"cell_type": "markdown",
4141
"metadata": {},
4242
"source": [
43-
"## To display a web scene in your notebook, query the `WebMap` object."
43+
"## To display a web scene in your notebook, query the `Map` object."
4444
]
4545
},
4646
{
@@ -49,9 +49,9 @@
4949
"metadata": {},
5050
"outputs": [],
5151
"source": [
52-
"from arcgis.mapping import WebMap\n",
52+
"from arcgis.map import Map\n",
5353
"\n",
54-
"la_parks_trails = WebMap(webmap)\n",
54+
"la_parks_trails = Map(item=webmap)\n",
5555
"la_parks_trails"
5656
]
5757
},
@@ -68,7 +68,7 @@
6868
"metadata": {},
6969
"outputs": [],
7070
"source": [
71-
"op_layers = la_parks_trails.layers\n",
71+
"op_layers = la_parks_trails.content.layers\n",
7272
"print(\"The webmap has {} layers.\".format(len(op_layers)))"
7373
]
7474
},
@@ -78,7 +78,7 @@
7878
"metadata": {},
7979
"outputs": [],
8080
"source": [
81-
"for lyr in la_parks_trails.layers:\n",
81+
"for lyr in la_parks_trails.content.layers:\n",
8282
" print(\"{}\\n\\t{}\".format(lyr['id'], lyr['url']))"
8383
]
8484
}

labs/display_web_scene.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
},
9797
{
9898
"cell_type": "code",
99-
"execution_count": 5,
99+
"execution_count": null,
100100
"metadata": {},
101101
"outputs": [
102102
{
@@ -127,8 +127,8 @@
127127
}
128128
],
129129
"source": [
130-
"from arcgis.mapping import WebScene\n",
131-
"la_trails = WebScene(webscene_item)\n",
130+
"from arcgis.map import Scene\n",
131+
"la_trails = Scene(item=webscene_item)\n",
132132
"la_trails"
133133
]
134134
},
@@ -141,7 +141,7 @@
141141
},
142142
{
143143
"cell_type": "code",
144-
"execution_count": 9,
144+
"execution_count": null,
145145
"metadata": {
146146
"scrolled": true
147147
},
@@ -155,7 +155,7 @@
155155
}
156156
],
157157
"source": [
158-
"op_layers = la_trails['operationalLayers']\n",
158+
"op_layers = la_trails.content.layers\n",
159159
"print(\"The web scene has {} layers\".format(len(op_layers)))"
160160
]
161161
},

samples/05_content_publishers/Identify_Items_That_Use_Insecure_URLs.ipynb

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
},
3535
{
3636
"cell_type": "code",
37-
"execution_count": 4,
37+
"execution_count": null,
3838
"metadata": {},
3939
"outputs": [],
4040
"source": [
@@ -46,8 +46,7 @@
4646
"import logging\n",
4747
"log = logging.getLogger()\n",
4848
"\n",
49-
"from arcgis.mapping import WebMap\n",
50-
"from arcgis.mapping import WebScene\n",
49+
"from arcgis.map import Map, Scene\n",
5150
"from arcgis.gis import GIS\n",
5251
"\n",
5352
"# login with your admin profile\n",
@@ -148,7 +147,7 @@
148147
},
149148
{
150149
"cell_type": "code",
151-
"execution_count": 9,
150+
"execution_count": 2,
152151
"metadata": {},
153152
"outputs": [],
154153
"source": [
@@ -160,12 +159,18 @@
160159
" \"\"\"\n",
161160
" https_urls = []\n",
162161
" http_urls = []\n",
163-
" wm = WebMap(webmap_item)\n",
162+
" wm = Map(item=webmap_item)\n",
164163
"\n",
165164
" # Concatenate all operational layers and basemap layers to one list\n",
166-
" all_layers = list(wm.layers)\n",
167-
" if hasattr(wm.basemap, 'baseMapLayers'):\n",
168-
" all_layers += wm.basemap.baseMapLayers\n",
165+
" all_layers = []\n",
166+
" for operationalLayer in wm.content.layers:\n",
167+
" if hasattr(operationalLayer, 'layers'):\n",
168+
" for layer in operationalLayer.layers:\n",
169+
" all_layers.append({\"url\":layer.url})\n",
170+
" else:\n",
171+
" all_layers.append({\"url\":operationalLayer.url})\n",
172+
" if hasattr(wm.basemap.basemap, 'baseMapLayers'):\n",
173+
" all_layers += wm.basemap.basemap.baseMapLayers\n",
169174
"\n",
170175
" # Test all of the layers, return the results\n",
171176
" for layer in [layer for layer in all_layers \\\n",
@@ -190,7 +195,7 @@
190195
},
191196
{
192197
"cell_type": "code",
193-
"execution_count": 1,
198+
"execution_count": 43,
194199
"metadata": {},
195200
"outputs": [],
196201
"source": [
@@ -202,17 +207,17 @@
202207
" \"\"\"\n",
203208
" https_urls = []\n",
204209
" http_urls = []\n",
205-
" ws = WebScene(webscene_item)\n",
210+
" ws = Scene(item=webscene_item)\n",
206211
"\n",
207212
" # Concatenate all operational layers and basemap layers to one list\n",
208213
" all_layers = []\n",
209-
" for operationalLayer in ws.get('operationalLayers', []):\n",
210-
" if 'layers' in operationalLayer:\n",
211-
" for layer in operationalLayer['layers']:\n",
212-
" all_layers.append(layer)\n",
214+
" for operationalLayer in ws.content.layers:\n",
215+
" if hasattr(operationalLayer, 'layers'):\n",
216+
" for layer in operationalLayer.layers:\n",
217+
" all_layers.append({\"url\":layer.url})\n",
213218
" else:\n",
214-
" all_layers.append(operationalLayer)\n",
215-
" for bm_layer in ws.get('baseMap', {}).get('baseMapLayers', []):\n",
219+
" all_layers.append({\"url\":operationalLayer.url})\n",
220+
" for bm_layer in ws.basemap.basemap.get('baseMapLayers', []):\n",
216221
" all_layers.append(bm_layer)\n",
217222
"\n",
218223
" # Test all of the layers, return the results\n",
@@ -240,7 +245,7 @@
240245
},
241246
{
242247
"cell_type": "code",
243-
"execution_count": 11,
248+
"execution_count": 44,
244249
"metadata": {},
245250
"outputs": [],
246251
"source": [
@@ -285,7 +290,7 @@
285290
},
286291
{
287292
"cell_type": "code",
288-
"execution_count": 37,
293+
"execution_count": 45,
289294
"metadata": {},
290295
"outputs": [],
291296
"source": [
@@ -574,9 +579,7 @@
574579
{
575580
"cell_type": "code",
576581
"execution_count": 58,
577-
"metadata": {
578-
"scrolled": false
579-
},
582+
"metadata": {},
580583
"outputs": [
581584
{
582585
"name": "stdout",
@@ -1026,7 +1029,7 @@
10261029
"name": "python",
10271030
"nbconvert_exporter": "python",
10281031
"pygments_lexer": "ipython3",
1029-
"version": "3.10.13"
1032+
"version": "3.13.5"
10301033
},
10311034
"toc": {
10321035
"base_numbering": 1,
@@ -1043,5 +1046,5 @@
10431046
}
10441047
},
10451048
"nbformat": 4,
1046-
"nbformat_minor": 2
1049+
"nbformat_minor": 4
10471050
}

samples/05_content_publishers/publish_ogc_services.ipynb

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@
2727
},
2828
{
2929
"cell_type": "code",
30-
"execution_count": 1,
30+
"execution_count": null,
3131
"metadata": {},
3232
"outputs": [],
3333
"source": [
3434
"from arcgis.gis import GIS\n",
35-
"from arcgis.mapping.layers import WMTSLayer, WMSLayer\n",
35+
"from arcgis.layers import WMTSLayer, WMSLayer\n",
3636
"from arcgis.map import Map\n",
3737
"\n",
3838
"gis = GIS(\"home\")"
@@ -451,7 +451,7 @@
451451
"execution_count": null,
452452
"metadata": {},
453453
"outputs": [
454-
{
454+
{
455455
"data": {
456456
"text/plain": [
457457
"True"
@@ -665,7 +665,8 @@
665665
"cell_type": "code",
666666
"execution_count": null,
667667
"metadata": {},
668-
"outputs": [{
668+
"outputs": [
669+
{
669670
"data": {
670671
"text/plain": [
671672
"True"
@@ -674,7 +675,8 @@
674675
"execution_count": 43,
675676
"metadata": {},
676677
"output_type": "execute_result"
677-
}],
678+
}
679+
],
678680
"source": [
679681
"item.delete(permanent=True)"
680682
]
@@ -1220,7 +1222,7 @@
12201222
"cell_type": "markdown",
12211223
"metadata": {},
12221224
"source": [
1223-
"Now, let's print the WebMap object containing the WFS service as below. Once the print job is triggered, user will be directed to `printed_file_url` (e.g. `https://<your org>.arcgis.com/home/webmap/print.html`) to download the file. Note that, for OGC WFS layers, the coordinate system of the basemap must be supported by the WFS service or the layer may not be drawn successfully. Map Viewer or Map Viewer Classic will not switch to use a compatible basemap. If the basemap is not compatible with the WFS layer, Map Viewer or Map Viewer Classic will display a message to that effect. In this case, we have used a WFS that supports `EPSG:3857`."
1225+
"Now, let's print the `Map` object containing the WFS service as below. Once the print job is triggered, user will be directed to `printed_file_url` (e.g. `https://<your org>.arcgis.com/home/webmap/print.html`) to download the file. Note that, for OGC WFS layers, the coordinate system of the basemap must be supported by the WFS service or the layer may not be drawn successfully. Map Viewer or Map Viewer Classic will not switch to use a compatible basemap. If the basemap is not compatible with the WFS layer, Map Viewer or Map Viewer Classic will display a message to that effect. In this case, we have used a WFS that supports `EPSG:3857`."
12241226
]
12251227
},
12261228
{
@@ -1286,7 +1288,7 @@
12861288
"name": "python",
12871289
"nbconvert_exporter": "python",
12881290
"pygments_lexer": "ipython3",
1289-
"version": "3.11.10"
1291+
"version": "3.13.5"
12901292
}
12911293
},
12921294
"nbformat": 4,

0 commit comments

Comments
 (0)