|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "metadata": {}, |
| 6 | + "source": [ |
| 7 | + "# Display Web Map ArcGIS DevLab\n", |
| 8 | + "This is the completed solution for the [Display a Web Map](https://developers.arcgis.com/labs/data/python/display-webmap/) 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" |
| 9 | + ] |
| 10 | + }, |
| 11 | + { |
| 12 | + "cell_type": "code", |
| 13 | + "execution_count": 1, |
| 14 | + "metadata": { |
| 15 | + "collapsed": true |
| 16 | + }, |
| 17 | + "outputs": [], |
| 18 | + "source": [ |
| 19 | + "from arcgis.gis import GIS\n", |
| 20 | + "\n", |
| 21 | + "gis = GIS(\"https://www.arcgis.com\")" |
| 22 | + ] |
| 23 | + }, |
| 24 | + { |
| 25 | + "cell_type": "markdown", |
| 26 | + "metadata": {}, |
| 27 | + "source": [ |
| 28 | + "Let's search for a Los Angeles Parks and Trails Map. " |
| 29 | + ] |
| 30 | + }, |
| 31 | + { |
| 32 | + "cell_type": "code", |
| 33 | + "execution_count": 2, |
| 34 | + "metadata": {}, |
| 35 | + "outputs": [ |
| 36 | + { |
| 37 | + "data": { |
| 38 | + "text/plain": [ |
| 39 | + "[<Item title:\"Tree Canopy by City in Minnesota\" type:Web Map owner:vikalpa>,\n", |
| 40 | + " <Item title:\"San Diego Shortlist-Copy\" type:Web Map owner:opsdashboarddemo>,\n", |
| 41 | + " <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", |
| 44 | + " <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", |
| 46 | + " <Item title:\"San Diego Places To Go-Copy\" type:Web Map owner:hayam_osama>,\n", |
| 47 | + " <Item title:\"Vaals9\" type:Web Map owner:haicao1975>,\n", |
| 48 | + " <Item title:\"San Diego Shortlist-Copia\" type:Web Map owner:paoloprova>]" |
| 49 | + ] |
| 50 | + }, |
| 51 | + "execution_count": 2, |
| 52 | + "metadata": {}, |
| 53 | + "output_type": "execute_result" |
| 54 | + } |
| 55 | + ], |
| 56 | + "source": [ |
| 57 | + "webmaps = gis.content.search(query=\"LA Parks and Trails *\", item_type=\"Web Map\")\n", |
| 58 | + "webmaps" |
| 59 | + ] |
| 60 | + }, |
| 61 | + { |
| 62 | + "cell_type": "markdown", |
| 63 | + "metadata": {}, |
| 64 | + "source": [ |
| 65 | + "The index position for the LA Parks and Trails Map in your search list may vary from the example." |
| 66 | + ] |
| 67 | + }, |
| 68 | + { |
| 69 | + "cell_type": "code", |
| 70 | + "execution_count": 3, |
| 71 | + "metadata": {}, |
| 72 | + "outputs": [ |
| 73 | + { |
| 74 | + "data": { |
| 75 | + "text/html": [ |
| 76 | + "<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", |
| 77 | + " <div class=\"item_left\" style=\"width: 210px; float: left;\">\n", |
| 78 | + " <a href='https://www.arcgis.com/home/item.html?id=77919fc65fcb4e2eb35d6bfd3217d037' target='_blank'>\n", |
| 79 | + " <img src='https://www.arcgis.com/sharing/rest//content/items/77919fc65fcb4e2eb35d6bfd3217d037/info/thumbnail/ago_downloaded.png' class=\"itemThumbnail\">\n", |
| 80 | + " </a>\n", |
| 81 | + " </div>\n", |
| 82 | + "\n", |
| 83 | + " <div class=\"item_right\" style=\"float: none; width: auto; overflow: hidden;\">\n", |
| 84 | + " <a href='https://www.arcgis.com/home/item.html?id=77919fc65fcb4e2eb35d6bfd3217d037' target='_blank'><b>LA Parks and Trails Map (styled with popups)c</b>\n", |
| 85 | + " </a>\n", |
| 86 | + " <br/>Trails and parks in the LA area (styled with popups)<img src='https://www.arcgis.com/home/js/jsapi/esri/css/images/item_type_icons/maps16.png' style=\"vertical-align:middle;\">Web Map by cheangerlove\n", |
| 87 | + " <br/>Last Modified: July 10, 2017\n", |
| 88 | + " <br/>0 comments, 10 views\n", |
| 89 | + " </div>\n", |
| 90 | + " </div>\n", |
| 91 | + " " |
| 92 | + ], |
| 93 | + "text/plain": [ |
| 94 | + "<Item title:\"LA Parks and Trails Map (styled with popups)c\" type:Web Map owner:cheangerlove>" |
| 95 | + ] |
| 96 | + }, |
| 97 | + "execution_count": 3, |
| 98 | + "metadata": {}, |
| 99 | + "output_type": "execute_result" |
| 100 | + } |
| 101 | + ], |
| 102 | + "source": [ |
| 103 | + "webmap = webmaps[2]\n", |
| 104 | + "webmap" |
| 105 | + ] |
| 106 | + }, |
| 107 | + { |
| 108 | + "cell_type": "code", |
| 109 | + "execution_count": 6, |
| 110 | + "metadata": {}, |
| 111 | + "outputs": [ |
| 112 | + { |
| 113 | + "data": { |
| 114 | + "application/vnd.jupyter.widget-view+json": { |
| 115 | + "model_id": "c90306bdb16442178b019338eec3fb33" |
| 116 | + } |
| 117 | + }, |
| 118 | + "metadata": {}, |
| 119 | + "output_type": "display_data" |
| 120 | + } |
| 121 | + ], |
| 122 | + "source": [ |
| 123 | + "from arcgis.mapping import WebMap\n", |
| 124 | + "la_parks_trails = WebMap(webmap)\n", |
| 125 | + "la_parks_trails" |
| 126 | + ] |
| 127 | + }, |
| 128 | + { |
| 129 | + "cell_type": "code", |
| 130 | + "execution_count": 7, |
| 131 | + "metadata": {}, |
| 132 | + "outputs": [ |
| 133 | + { |
| 134 | + "name": "stdout", |
| 135 | + "output_type": "stream", |
| 136 | + "text": [ |
| 137 | + "The webmap has 3 layers.\n" |
| 138 | + ] |
| 139 | + } |
| 140 | + ], |
| 141 | + "source": [ |
| 142 | + "op_layers = la_parks_trails['operationalLayers']\n", |
| 143 | + "print(\"The webmap has {} layers.\".format(len(op_layers)))" |
| 144 | + ] |
| 145 | + }, |
| 146 | + { |
| 147 | + "cell_type": "code", |
| 148 | + "execution_count": 8, |
| 149 | + "metadata": {}, |
| 150 | + "outputs": [ |
| 151 | + { |
| 152 | + "name": "stdout", |
| 153 | + "output_type": "stream", |
| 154 | + "text": [ |
| 155 | + "Parks_and_Open_Space_8268\n", |
| 156 | + "\thttps://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Parks_and_Open_Space/FeatureServer/0\n", |
| 157 | + "Trails_7558\n", |
| 158 | + "\thttps://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trails/FeatureServer/0\n", |
| 159 | + "Trailheads_8053\n", |
| 160 | + "\thttps://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads/FeatureServer/0\n" |
| 161 | + ] |
| 162 | + } |
| 163 | + ], |
| 164 | + "source": [ |
| 165 | + "for lyr in la_prk_trails_webmap['operationalLayers']:\n", |
| 166 | + " print(\"{}\\n\\t{}\".format(lyr['id'], lyr['url']))" |
| 167 | + ] |
| 168 | + } |
| 169 | + ], |
| 170 | + "metadata": { |
| 171 | + "anaconda-cloud": {}, |
| 172 | + "kernelspec": { |
| 173 | + "display_name": "Python [default]", |
| 174 | + "language": "python", |
| 175 | + "name": "python3" |
| 176 | + }, |
| 177 | + "language_info": { |
| 178 | + "codemirror_mode": { |
| 179 | + "name": "ipython", |
| 180 | + "version": 3 |
| 181 | + }, |
| 182 | + "file_extension": ".py", |
| 183 | + "mimetype": "text/x-python", |
| 184 | + "name": "python", |
| 185 | + "nbconvert_exporter": "python", |
| 186 | + "pygments_lexer": "ipython3", |
| 187 | + "version": "3.5.3" |
| 188 | + } |
| 189 | + }, |
| 190 | + "nbformat": 4, |
| 191 | + "nbformat_minor": 1 |
| 192 | +} |
0 commit comments