- \n"]}],"source":["# We can see from the output that the title is being updated:\n","print(webmap_item)"]},{"cell_type":"markdown","metadata":{},"source":["## Creating static maps via `take_screenshot`\n","\n","Since version 1.5.2, the ArcGIS API for Python supports the `take_screenshot()` method, which will create a screenshot of the current widget view. Note that the method only works in a Jupyter Notebook environment.\n","\n","```\n","take_screenshot(output_in_cell=True, set_as_preview=True, file_path='')\n","```\n","\n","The method takes the following arguments:\n","\n","- `output_in_cell`: Optional boolean that defaults to True. This will display the screenshot in the output area of the cell where this function is called.\n","- `set_as_preview`: Optional boolean that defaults to True. This will set the screenshot as the static image preview in the cell where the map widget is being displayed. Use this flag if you want the generated HTML previews of your notebook to have a map image visible.\n","- `file_path`: Optional String that defaults to “”. To output the screenshot to a .png file on disk, set this String to a writeable location file path (Ex. file_path = “/path/to/documents/my_screenshot.png”).\n","\n","In all notebook outputs, each image will be encoded to a base64 data URI and wrapped in an HTML tag. This means that the data for the image lives inside the notebook file itself, allowing for easy sharing of notebooks and generated HTML previews of notebooks.\n","\n","
\n"," Note: This function acts asynchronously, meaning that the Python function will return right away, with the notebook outputs/files being written after an indeterminate amount of time. Avoid calling this function multiple times in a row if the asynchronous portion of the function has not finished yet.\n","
\n","\n","\n"," Another Note: Some limitations exist for taking screenshots in 2D mode, since the underlying screenshot mechanism is the ArcGIS JS API’s PrintTask object (https://bit.ly/2qRKGJG). If this function fails to create a screenshot, try a slightly different extent and try again. Non-published features with client-side graphics like Spatially Enabled DataFrames might not display in a 2D mode screenshot.\n","
\n"]},{"cell_type":"code","execution_count":6,"metadata":{},"outputs":[{"data":{"text/html":[""],"text/plain":[""]},"metadata":{},"output_type":"display_data"}],"source":["map1.take_screenshot()"]},{"cell_type":"markdown","metadata":{},"source":["## Export live map in a separate HTML file\n","\n","Another new feature in 1.5.0 is the ability to export the current widget as a stand-alone HTML file. This added functionality provides a new workflow for creating standalone HTML maps that can be shared with anyone. All they need is a web browser!\n","\n","The cell below will write the current widget to the file specified by a string path. Run the cell, find the file on your disk, and open it in your favorite web browser.\n","\n","\n"," Note: By default, only publicly accessible layers will show on the exported HTML maps. You must specify that `credentials_prompt=True` to allow users to authenticate to the GIS to view private layers. See the API reference for more information.\n","
\n"]},{"cell_type":"code","execution_count":90,"metadata":{},"outputs":[{"name":"stdout","output_type":"stream","text":["html saved as C:\\Users\\Username\\Documents\\home\\myWorldMap.html\n"]}],"source":["import os\n","\n","file_dir = os.path.join(os.getcwd(), 'home')\n","if not os.path.isdir(file_dir):\n"," os.mkdir(file_dir)\n","\n","file_path = os.path.join(file_dir, 'myWorldMap.html')\n","\n","map1.export_to_html(file_path)\n","print(\"html saved as \" + file_path)"]},{"cell_type":"markdown","metadata":{},"source":["## Embedding a live map\n","\n","The `embed` method embeds the current state of the map into the underlying notebook as an interactive HTML/JS/CSS element.\n","\n","```\n","embed(output_in_cell=True, set_as_preview=True)\n","```\n","\n","Its arguments include:\n","\n","- `output_in_cell`: Optional boolean that defaults to `True`. This will display the embedded HTML interactive map in the output area of the cell where this function is called.\n","- `set_as_preview`: Optional boolean that defaults to `True`. This will display the embedded HTML interactive map in the cell where the map widget is being displayed. Use this flag if you want the generated HTML previews of your notebook to have an interactive map displayed.\n","\n","\n"," Note: This element will always display this `snapshot` state of the map, regardless of any future Python code ran.\n","
\n"]},{"cell_type":"markdown","metadata":{},"source":["In all notebook outputs, each embedded HTML element will contain the entire map state and all relevant HTML wrapped in an `