{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Display Web Map ArcGIS DevLab\n", "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" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": true }, "outputs": [], "source": [ "from arcgis.gis import GIS\n", "\n", "gis = GIS(\"https://www.arcgis.com\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's search for a Los Angeles Parks and Trails Map. " ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ]" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "webmaps = gis.content.search(query=\"LA Parks and Trails *\", item_type=\"Web Map\")\n", "webmaps" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The index position for the LA Parks and Trails Map in your search list may vary from the example." ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "
\n", " \n", " \n", " \n", "
\n", "\n", "
\n", " LA Parks and Trails Map (styled with popups)c\n", " \n", "
Trails and parks in the LA area (styled with popups)Web Map by cheangerlove\n", "
Last Modified: July 10, 2017\n", "
0 comments, 10 views\n", "
\n", "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "webmap = webmaps[2]\n", "webmap" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## To display a web scene in your notebook, query the `WebMap` object." ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "8310f2d7aa1d4625bbe84835deb8b745" } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from arcgis.mapping import WebMap\n", "la_parks_trails = WebMap(webmap)\n", "la_parks_trails" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Challenge" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The webmap has 3 layers.\n" ] } ], "source": [ "op_layers = la_parks_trails['operationalLayers']\n", "print(\"The webmap has {} layers.\".format(len(op_layers)))" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Parks_and_Open_Space_8268\n", "\thttps://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Parks_and_Open_Space/FeatureServer/0\n", "Trails_7558\n", "\thttps://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trails/FeatureServer/0\n", "Trailheads_8053\n", "\thttps://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads/FeatureServer/0\n" ] } ], "source": [ "for lyr in la_parks_trails['operationalLayers']:\n", " print(\"{}\\n\\t{}\".format(lyr['id'], lyr['url']))" ] } ], "metadata": { "anaconda-cloud": {}, "kernelspec": { "display_name": "Python [default]", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.5.3" } }, "nbformat": 4, "nbformat_minor": 1 }