arcgis.widgets module¶
MapView¶
-
class
arcgis.widgets.
MapView
(**kwargs)¶ Bases:
ipywidgets.widgets.domwidget.DOMWidget
The
MapView
class creates a mapping widget for Jupyter Notebook and JupyterLab.Parameter
Description
gis
The active
GIS
instance you want this map widget to use.item
A
WebMap
orWebScene
item instance that you want to visualizemode
Whether to construct a ‘2D’ map or ‘3D’ map. See the
mode
property for more information.Note
If the Jupyter Notebook server is running over http, you need to configure your portal/organization to allow your host and port; or else you will run into
CORS
issues.This can be accomplished programmatically by signing into your organization and running this code:
>>> from arcgis.gis import GIS >>> gis = GIS(profile="your_admin_profile") >>> more_origins = {"allowedOrigins":"http://localhost:8888"} #replace your port >>> gis.update_properties(more_origins)
-
add_layer
(item, options=None)¶ The
add_layer
method adds the specifiedLayer
orItem
to the map widget.Parameter
Description
item
Required object. You can specify
Item
objects,Layer
objects such asFeatureLayer
, ImageryLayer, MapImageLayer,FeatureSet
,Collection
,Raster
objects, etc.Item
objects will have all of their layers individually added to the map widget.options
Optional dict. Specify visualization options such as renderer info, opacity, definition expressions. See example below
Warning
Calling
MapView.add_layer()
on anRaster
instance has the following limitations:Local raster overlays do not persist beyond the notebook session on published web maps/web scenes – you would need to separately publish these local rasters.
The entire raster image data is placed on the MapView’s canvas with no performance optimizations. This means no pyramids, no dynamic downsampling, etc. Please be mindful of the size of the local raster and your computer’s hardware limitations.
Pixel values and projections are not guaranteed to be accurate, especially when the local raster’s Spatial Reference doesn’t reproject accurately to Web Mercator (what the
MapView
widget uses).
# USAGE EXAMPLE: Add a feature layer with smart mapping renderer and # a definition expression to limit the features drawn. map1 = gis.map("Seattle, WA") map1.add_layer(wa_streets_feature_layer, {'renderer':'ClassedSizeRenderer', 'field_name':'DistMiles', 'opacity':0.75})
-
property
basemap
¶ Get/Set the basemap you would like to apply to the widget.
Parameter
Description
value
Required string. Ex: (‘topo’, ‘national-geographic’, etc.).
Note
See
basemaps
for a full list of options.- Returns
basemap being used.
# Usage example: Set the widget basemap equal to an item >>> from arcgis.mapping import WebMap >>> widget = gis.map() >>> # Use basemap from another item as your own >>> widget.basemap = webmap >>> widget.basemap = tiled_map_service_item >>> widget.basemap = image_layer_item >>> widget.basemap = webmap2.basemap >>> widget.basemap - 'national-geographic'
-
property
basemaps
¶ The
basemaps
layers are a list of possible basemaps to setbasemap
with:Dark Grey Vector
Gray Vector
Hybrid
Oceans
OSM
Satellite
Streets Navigation Vector
Streets Night Vector
Streets Relief Vector
Streets Vector
Terrain
Topographic Vector
There are basemap layers available if you are authenticated or provide an api key.
ArcGIS Imagery
ArcGIS Imagery Standard
ArcGIS Imagery Labels
ArcGIS Light Gray
ArcGIS Dark Gray
ArcGIS Navigation
ArcGIS Navigation Night
ArcGIS Streets
ArcGIS Streets Night
ArcGIS Streets Relief
ArcGIS Topographic
ArcGIS Oceans
ArcGIS Standard
ArcGIS Standard Relief
ArcGIS Streets
ArcGIS Streets Relief
ArcGIS Open Street Map Light Gray
ArcGIS Open Street Map Dark Gray
ArcGIS Terrain
ArcGIS Community
ArcGIS Charted Territory
ArcGIS Colored Pencil
ArcGIS Nova
ArcGIS Modern Antique
ArcGIS Midcentury
ArcGIS Newspaper
ArcGIS Hillshade Light
ArcGIS Hillshade Dark
ArcGIS Human Geography
ArcGIS Human Geography Dark
-
property
center
¶ Get/Set the center of the
Map Widget
.Parameter
Description
setter
A [lat, long] list, or a dict that represents the JSON of the map widget’s center.
- Returns
A dict that represents the JSON of the map widget’s center.
#Usage Example >>> from arcgis.gis import GIS, Item >>> from arcgis.widgets import MapView >>> map2 = gis.map("California") >>> map2 >>> map2.center { 'spatialReference': {'latestWkid': 3857, 'wkid': 102100}, 'x': -13277101.270396618, 'y': 4374001.4894094905 }
-
clear_graphics
()¶ The
clear_graphics
method clear the graphics drawn on the map widget.Note
Graphics are shapes drawn using the
draw
method.#Usage Example: Drawing two Geometry objects on a map widget. >>> from arcgis.gis import GIS, Item >>> from arcgis.widgets import MapView >>> from arcgis.geometry import Geometry, Polygon >>> geom = Geometry({ "rings" : [[[-97.06138,32.837],[-97.06133,32.836],[-97.06124,32.834],[-97.06127,32.832], [-97.06138,32.837]],[[-97.06326,32.759],[-97.06298,32.755],[-97.06153,32.749], [-97.06326,32.759]]], "spatialReference" : {"wkid" : 4326} }) >>> map2 = gis.map("Arlington, Texas") >>> map2.draw(shape=geom) >>> map2 <Map Widget Displayed with the drawn Polygons> >>> map2.clear_graphics() >>> map2 <Map Widget Displayed without the drawn Polygons>
-
display_message
(msg)¶ The
display_message
method displays a message on the upper-right corner of themap widget
.Note
Only one message can be sent at a time, multiple messages do not show up.
-
draw
(shape, popup=None, symbol=None, attributes=None)¶ The
draw
method draws a shape on the map widget.Note
Anything can be drawn from known
Geometry
objects, coordinate pairs, andFeatureSet
objects.Parameter
Description
shape
Required object. Known
Geometry
objects: Shape is one of [circle
,ellipse
,Polygon
,Polyline
,MultiPoint
,Point
,rectangle
,triangle
].Coordinate pair: specify shape as a list of [lat, long]. Eg: [34, -81]
FeatureSet: shape can be a
FeatureSet
object.Dict object representing a geometry.
popup
Optional dict. Dict containing
title
andcontent
as keys that will be displayed when the shape is clicked. In case of aFeatureSet
,title
andcontent
are names of attributes of the features in theFeatureSet
instead of actual string values fortitle
andcontent
.symbol
Optional dict. See the Symbol Objects page in the ArcGIS REST API documentation for more information. A default symbol is used if one is not specified.
A helper utility to get the symbol format for several predefined symbols is available at the Esri symbol selector.
attributes
Optional dict. Specify a dict containing name value pairs of fields and field values associated with the graphic.
#Usage Example: Drawing two Geometry objects on a map widget. >>> from arcgis.gis import GIS, Item >>> from arcgis.widgets import MapView >>> from arcgis.geometry import Geometry, Polygon >>> geom = Geometry({ "rings" : [[[-97.06138,32.837],[-97.06133,32.836],[-97.06124,32.834],[-97.06127,32.832], [-97.06138,32.837]],[[-97.06326,32.759],[-97.06298,32.755],[-97.06153,32.749], [-97.06326,32.759]]], "spatialReference" : {"wkid" : 4326} }) >>> map2 = gis.map("Arlington, Texas") >>> map2.draw(shape=geom) >>> map2 <Map Widget Displayed with the drawn Polygons>
-
embed
(output_in_cell=True, set_as_preview=True)¶ The
embed
method embeds the current state of the map into the underlying notebook as an interactive HTML/JS/CSS element.Note
This element will always display this ‘snapshot’ state of the map, regardless of any future Python code ran.
Parameter
Description
output_in_cell
Optional bool, default
True
. Will display the embedded HTML interactive map in the output area of the cell where this function is called.set_as_preview
Optional bool, default True. 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.
In all notebook outputs, each embedded HTML element will contain the entire map state and all relevant HTML wrapped in an <iframe> element. This means that the data for the embedded HTML element lives inside the notebook file itself, allowing for easy sharing of notebooks and generated HTML previews of notebooks.
Note
When this function is called with
set_as_preview = True
, the embedded HTML preview element will overwrite the static image preview from any previous MapView.take_screenshot(set_as_preview=True) callNote
Any embedded maps must only reference publicly available data. The embedded map must also have access to the Unpkg to load the necessary JavaScript components on the page
-
property
end_time
¶ end_time
is adatetime.datetime
property. Iftime_mode
==time-window
end_time
represents the upper bound ‘thumb’ of the time slider. For all othertime_mode
values,end_time
is not used.
-
export_to_html
(path_to_file, title='Exported ArcGIS Map Widget', credentials_prompt=False)¶ The
export_to_html
method takes the current state of the map widget and exports it to a standalone HTML file that can be viewed in any web browser.By default, only publicly viewable layers will be visible in any exported html map. Specify
credentials_prompt=True
to have a user be prompted for their credentials when opening the HTML page to view private content.Warning
Follow best security practices when sharing any HTML page that prompts a user for a password.
Note
You cannot successfully authenticate if you open the HTML page in a browser locally like file://path/to/file.html. The credentials prompt will only properly function if served over a HTTP/HTTPS server.
Parameter
Description
path_to_file
Required string. The path to save the HTML file on disk.
title
Optional string. The HTML title tag used for the HTML file.
credentials_prompt
Optional boolean, default
False
. If set toTrue
, will display a credentials prompt on HTML page load for users to authenticate and view private content.
-
property
extent
¶ Get/Set the map widget’s extent.
Parameter
Description
value
- Required dict.
A [[xmin, ymin], [xmax, ymax]] list, Spatially Enabled Data Frame
full_extent
, or a dict that represents the JSON of the map widget’s extent.Examples for each: web_map.extent = [[-124.35, 32.54], [-114.31, 41.95]] web_map.extent = data_frame.spatial.full_extent web_map.extent = {
“xmin”: -124.35, “ymin”: 32.54, “xmax”: -114.31, “ymax”: 41.95
}
#Usage Example >>> from arcgis.gis import GIS, Item >>> from arcgis.widgets import MapView >>> map2 = gis.map("California") >>> map2.extent { 'xmin': -124.20822999999997, 'ymin': 31.436105693000048, 'xmax': -114.33222999999997, 'ymax': 41.31210569300005 }
-
property
gallery_basemaps
¶ The
gallery_basemaps
property allows for viewing of your portal’s custom basemap group.
-
property
heading
¶ Get/Set the compass heading of the camera in degrees when in 3D mode.
heading
is zero when north is the top of the screen. It increases as the view rotates clockwise. The angles are always normalized between 0 and 360 degrees.Note
heading
cannot be set in 2D mode. Rather, 2D mode uses therotation
property.#Usage Example in 3D mode >>> from arcgis.gis import GIS, Item >>> from arcgis.widgets import MapView >>> map3d = gis.map("California", mode ="3D") >>> map3d.heading <225.82433689241765>
-
hide_mode_switch
¶ When
hide_mode_switch
is set toTrue
the 2D/3D switch button will be hidden from the widget.Note
Once the button is hidden, it cannot be made visible again: a new MapView instance must be created to see the button.
-
jupyter_target
¶ jupyter_target
is a readonly string that is eitherlab
ornotebook
:jupyter_target
represents if this widget is drawn in a Jupyter Notebook environment or a JupyterLab environment.
-
property
layers
¶ The
layers
property is a list of the JSON representation of layers added to the map widget using theadd_layers
method.#Usage Example in 2D mode >>> from arcgis.gis import GIS, Item >>> from arcgis.widgets import MapView >>> gis = GIS("pro") >>> itms = gis.content.search("owner:"+ gis.users.me.username) >>> single_item =itms[1] >>> new_layer= FeatureLayer.fromitem(item = single_item) >>> map1 = gis.map("United States") >>> map1.add_layer(new_layer) >>> map1.layers [<FeatureLayer url:"https://services7.arcgis.com/JEwYeAy2cc8qOe3o/arcgis/rest/services/Power_Plants_Itm/FeatureServer/0">]
-
legend
¶ If
legend
is set toTrue
, a legend will display in the widget that describes all layers added to the map. If set toFalse
,the legend will be hidden.Note
The default is
False
.
-
property
local_raster_file_format
¶ The
local_raster_file_format
method is a string getter & setter. When callingmap.add_layer(arcgis.raster.Raster())
for a local raster file, an intermediate image file must be written to disk in order to successfully display on the map. This file format can be one of the following:Possible Values
Description
"jpg"
(Default)Write raster to a
.JPG
file. This results in a lossy image, but should draw quicker than a.PNG
file. Requires thePIL
image processing package (distributed under the name of it’s active fork, “Pillow”)"png"
Write raster to a
.PNG
file. This results in a lossless image, but it might take a longer time to draw than a.JPG
file.
-
mode
¶ The string that specifies whether the map displays in ‘2D’ mode (MapView) or ‘3D’ mode (SceneView). Possible values: ‘2D’, ‘3D’.
Note that you can also toggle between '2D' and '3D' mode by pressing the icon in the widget UI.
-
on_click
(callback, remove=False)¶ The
on_click
method registers a callback to execute when the map is clicked.Note
The callback will be called with one argument, the clicked widget instance.
Parameter
Description
remove
Optional boolean. Set to true to remove the callback from the list of callbacks.
-
on_draw_end
(callback, remove=False)¶ The
on_draw_end
method registers a callback to execute when something is drawn. The callback will be called with two arguments: 1. The clicked widget instance 2. The drawn geometryParameter
Description
remove
Optional boolean. Set to true to remove the callback from the list of callbacks.
-
print_service_url
¶ Warning
This property is obselete as of >v1.6 of the Python API, since the underlying JavaScript code ran during a take_screenshot() Python call has been has been changed to MapView.takeScreenshot() instead of calling a Print Service URL. Any value you set to this property will be ignored (2D screenshots will still be taken successfully).
-
ready
¶ ready
is a readonly bool that represents if the map widget has been drawn in the notebook.
-
remove_layers
(layers=None)¶ The
remove_layers
method removes the layers added to the map widget.Note
A list of layers added to the widget can be retrieved by querying the
layers
property.Parameter
Description
layers
Optional list. Specify the list of layers to be removed from the map widget. You can get the list of layers on the map by querying the ‘layers’ property. If not specified, it removes all layers added to the widget.
- Returns
True if layer is successfully removed. Else, False.
-
property
rotation
¶ Get/Set the clockwise rotation of due north in relation to the top of the view in degrees in 2D mode.
Parameter
Description
value
Required float.
Note
rotation
cannot be set in 3D mode. Rather, 3D mode uses theheading
property.#Usage Example in 2D mode >>> from arcgis.gis import GIS, Item >>> from arcgis.widgets import MapView >>> map2 = gis.map("California") >>> map2.rotation <134.17566310758235>
-
save
(item_properties, mode=None, thumbnail=None, metadata=None, owner=None, folder=None)¶ The
save
method saves the map widget object into a new web mapItem
or a new web scene item in your GIS.Note
If you started out with a fresh map widget object, use this method to save it as a the webmap/webscene item in your
GIS
. If you started with a map widget object from an existing webmap/webscene object, calling this method will create a new item with your changes. If you want to update the existing item with your changes, call theupdate
method instead.Note
Saving as a WebScene item only works in a Jupyter environment: the map must be visually displayed in the notebook before calling this method.
Parameter
Description
item_properties
Required dictionary. See table below for the keys and values.
mode
Optional string. Whether to save this map instance as a 2D WebMap, or a 3D WebScene. Possible strings: “2D”, “webmap”, “3D”, or “webscene”.
thumbnail
Optional string. Either a path or URL to a thumbnail image.
metadata
Optional string. Either a path or URL to the metadata.
owner
Optional string. User object corresponding to the desired owner of this item. Defaults to the logged in user.
folder
Optional string. Name of the folder where placing item.
Key:Value Dictionary Options for Parameter item_properties
Key
Value
typeKeywords
Optional string. Provide a lists all sub-types, see URL 1 below for valid values.
description
Optional string. Description of the item.
title
Optional string. Name label of the item.
tags
Optional string. Tags listed as comma-separated values, or a list of strings. Used for searches on items.
snippet
Optional string. Provide a short summary (limit to max 250 characters) of the what the item is.
accessInformation
Optional string. Information on the source of the content.
licenseInfo
Optional string. Any license information or restrictions regarding the content.
culture
Optional string. Locale, country and language information.
access
Optional string. Valid values are private, shared, org, or public.
commentsEnabled
Optional boolean. Default is true, controls whether comments are allowed (true) or not allowed (false).
culture
Optional string. Language and country information.
- Returns
Item object corresponding to the new web map Item created.
USAGE EXAMPLE: Save map widget as a new web map item in GIS map1 = gis.map("Italy") map1.add_layer(Italy_streets_item) map1.basemap = 'dark-gray-vector' italy_streets_map = map1.save({'title':'Italy streets', 'snippet':'Arterial road network of Italy', 'tags':'streets, network, roads'})
-
property
scale
¶ Get/Set the map scale at the center of the view. If set to X, the scale of the map would be 1:X.
Parameter
Description
value
Required int.
Note
For continuous values to apply and not get “snapped” to the closest level of detail, set mapview.snap_to_zoom = False.
# Usage example: Sets the scale to 1:24000 map = gis.map() map.scale = 24000
-
classmethod
set_js_cdn
(js_cdn)¶ The
set_js_cdn
function is called before the creation of any MapView object, and each instantiated object will use the specifiedjs_cdn
parameter as the ArcGIS API for JavaScript CDN URL instead of the default http://js.arcgis.com/4.X/. This functionality is necessary in disconnected environments if the portal you are connecting to doesn’t ship with the minimum necessary JavaScript API version.Note
You may not need to call this function to view the widget in disconnected environments: if your computer cannot reach js.arcgis.com, and you have a
GIS
connection to a portal, the widget will automatically attempt to use that Portal’s JS API that it ships with.
-
set_time_extent
(start_time, end_time, interval=1, unit='milliseconds')¶ The
set_time_extent
is called when time_slider = True and is the time extent to display on the time slider.Parameter
Description
start_time
Required
datetime.datetime
. The lower bound of the time extent to display on the time slider.end_time
Required
datetime.datetime
. The upper bound of the time extent to display on the time slider.interval
Optional number, default 1. The numerical value of the time extent.
unit
Optional string, default “milliseconds”. Temporal units. Possible values: “milliseconds”, “seconds”, “minutes”, “hours”, “days”, “weeks”, “months”, “years”, “decades”, “centuries”
-
property
snap_to_zoom
¶ The
snap_to_zoom
property is used to determine how the zoom is enabled when the map widget is created.Parameter
Description
value
Required bool. Values:
True: snap to the next level of detail when zooming in or out.
False: the zoom is continuous.
Note
The
snap_to_zoom
method only applies in 2D mode.
-
property
start_time
¶ The
start_time
property is a representation of a datetime.datetime property. If time_mode == “time-window”, represents the lower bound ‘thumb’ of the time slider. For all other time_mode values,start_time
represents the single thumb on the time slider.
The
sync_navigation
method synchronizes the navigation from thisMapView
to anotherMapView
instance so panning/zooming/navigating in one will update the other.Note
Users can sync more than two class:~arcgis.widgets.MapView instances together. For example, a user can sync MapView A to MapView B, MapView B to MapView C, and MapView C to MapView D together and all will be in sync. Thus, driving one of these
MapView
objects will make the otherMapView
objects follow.Parameter
Description
mapview
Either a single
MapView
instance, or a list ofMapView
instances to synchronize to.# USAGE EXAMPLE: link the navigation of two maps together from ipywidgets import HBox map1 = gis.map("Chicago, IL") map1.basemap = "gray" map2 = gis.map("Chicago, IL") map2.basemap = "dark-gray" map1.sync_navigation(map2) HBox([map1, map2])
-
tab_mode
¶ The ``tab_mode`` property is a string property that specifies the 'default' behavior of toggling a new window in a JupyterLab environment, whether that is called by pressing the icon in the widget UI, or by calling toggle_window_view() function without arguments.
Note
After a widget is ‘seperated’ from the notebook, you can drag it, split it, put it in a new tab, etc. See the JupyterLab guide pages for more information.
Value
Description
‘auto’
The default tab_mode: will move the widget to a split-right view if there are no other open windows besides the current notebook, otherwise will place the widget in a new tab.
‘split-top’
Will move the widget above the current notebook instance.
‘split-bottom’
Will move the widget below the current notebook instance.
‘split-left’
Will move the widget to the left of the current notebook instance.
‘split-right’
Will move the widget to the right of the current notebook instance.
‘tab-before’
Will move the widget to a new tab ‘before’ the tab that represents the current notebook instance.
‘tab-after’
Will move the widget to a new tab ‘after’ the tab that represents the current notebook instance.
-
take_screenshot
(output_in_cell=True, set_as_preview=True, file_path='')¶ The
take_screenshot
method takes a screenshot of the current widget view.Note
Only works in a Jupyter Notebook environment.
Parameter
Description
output_in_cell
Optional bool, default
True
. Will display the screenshot in the output area of the cell where this function is called.set_as_preview
Optional bool, default
True
. 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.file_path
Optional String, default “”. 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”).
In all notebook outputs, each image will be encoded to a base64 data URI and wrapped in an HTML <img> tag, like <img src=”base64Str”>. 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.
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 hasn’t finished yet.
Note
When this function is called with
set_as_preview = True
, the static image preview will overwrite the embedded HTML element preview from any previousMapView.embed_html(set_as_preview=True)
call
-
property
tilt
¶ Get/Set the tilt of the camera in degrees with respect to the surface as projected down from the camera position, when in 3D mode.
tilt
is zero when looking straight down at the surface and 90 degrees when the camera is looking parallel to the surface.Note
The
tilt
method is not applicable, and cannot be set, in 2D mode.
-
time_mode
¶ time_mode
is the string used for defining if the temporal data will be displayed cumulatively up to a point in time, a single instant in time, or within a time range.Possible values: “instant”, “time-window”, “cumulative-from-start”, “cumulative-from-end”. Default: “time-window”
See the TimeSlider page in the ArcGIS REST API page for more info.
-
time_slider
¶ time_slider
is a string property that determines whether a time slider exists for a map widget. If set to True, will display a time slider in the widget that will allow you to visualize temporal data for an applicable layer added to the map. Default: False.See the TimeSlider page in the ArcGIS REST API page for more info.
-
toggle_window_view
(title='ArcGIS Map', tab_mode=None)¶ In a JupyterLab environment, calling
toggle_window_view
will separate the drawn map widget to a new window next to the open notebook, allowing you to move the widget to it, split it, put it in a new tab, etc. If the widget is already separated in a new window, calling this function will restore the widget to the notebook where it originated from.Note
See the JupyterLab guide pages for more information.
Note that this functionality can also be achieved by pressing the icon in the widget UI.
Parameter
Description
title
What text will display as the widget tab. Default: “ArcGIS Map”.
tab_mode
The ‘tab mode’ that this window will open in. Will use this MapView instance’s tab_mode property if not specified. Possible values: “auto”, “split-top”, “split-left”, “split-right”, “split-bottom”, “tab-before”, “tab-after”
The
unsync_navigation
method unsynchronizes connections made to otherMapView
instances made via my_mapview.sync_navigation(other_mapview).Parameter
Description
mapview
(Optional) Either a single MapView instance, or a list of MapView instances to unsynchronize. If not specified, will unsynchronize all synced MapView instances
-
update
(mode=None, item_properties=None, thumbnail=None, metadata=None)¶ The
update
method updates the WebMap/Web Scene item that was used to create theMapWidget
object. In addition, you can update other item properties, thumbnail and metadata.Note
If you started out a MapView object from an existing webmap/webscene item, use this method to update the webmap/webscene item in your with your changes. If you started out with a fresh
MapView
object (without a webmap/webscene item), calling this method will raise a RuntimeError exception. If you want to save the map widget into a new item, call thesave
method instead. Foritem_properties
, pass in arguments for only the properties you want to be updated. All other properties will be untouched. For example, if you want to update only the item’s description, then only provide the description argument in item_properties.Note
Saving as a
WebScene
item only works in a Jupyter environment: the map must be visually displayed in the notebook before calling this method.Parameter
Description
item_properties
Optional dictionary. See table below for the keys and values.
mode
Optional string. Whether to save this map instance as a 2D WebMap, or a 3D WebScene. Possible strings:
2D
,webmap
,3D
, orwebscene
.thumbnail
Optional string. Either a path or URL to a thumbnail image.
metadata
Optional string. Either a path or URL to the metadata.
Key:Value Dictionary Options for Parameter item_properties
Key
Value
typeKeywords
Optional string. Provide a lists all sub-types, see URL 1 below for valid values.
description
Optional string. Description of the item.
title
Optional string. Name label of the item.
tags
Optional string. Tags listed as comma-separated values, or a list of strings. Used for searches on items.
snippet
Optional string. Provide a short summary (limit to max 250 characters) of the what the item is.
accessInformation
Optional string. Information on the source of the content.
licenseInfo
Optional string. Any license information or restrictions regarding the content.
culture
Optional string. Locale, country and language information.
access
Optional string. Valid values are private, shared, org, or public.
commentsEnabled
Optional boolean. Default is true, controls whether comments are allowed (true) or not allowed (false).
- Returns
A boolean indicating success (True) or failure (False).
USAGE EXAMPLE: Interactively add a new layer and change the basemap of an existing web map. italy_streets_item = gis.content.search("Italy streets", "Web Map")[0] map1 = MapView(item = italy_streets_item) map1.add_layer(Italy_streets2) map1.basemap = 'dark-gray-vector' map1.update(thumbnail = './new_webmap.png')
-
update_layer
(layer)¶ To update the layer dictionary for a layer in the map. For example, to update the renderer dictionary for a layer and have it by dynamically changed on the mapview.
Parameter
Description
layer
Required Feature Layer or Feature Layer dictionary. The existing mapview layer with updated properties. In order to get a layer on the mapview, use the
layers
method and assign the output to a value. Make edits on the this value and pass it in as a dict to update the rendering on the map.Warning
If the itemId of the feature layer is changed, this will not work.
# Create a mapview and add layer map1 = gis.map("Oregon") map1.add_layer(<fl_to_add>) # Get a layer and edit the color fl = map1.layers[0] fl.renderer.symbol.color = [0, 204, 204, 255] # Update the layer to see it render on map map1.update_layer(fl) # Save with the updates wm_properties= {"title": "Test Update", "tags":["update_layer"], "snippet":"Updated a layer and now save"} map1.save(wm_properties)
-
property
zoom
¶ Get/Set the level of zoom applied to the Map Widget.
Parameter
Description
value
Required int. .. note:
The higher the number, the more zoomed in you are.
- Returns
Int value that represent the zoom level
# Usage example >>> from arcgis.gis import GIS, Item >>> from arcgis.widgets import MapView >>> map2 = gis.map("California") >>> map2.basemap = 'national-geographic' >>> map2 >>> map2.zoom = 200
-
zoom_to_layer
(item, options={})¶ The
zoom_to_layer
method snaps the map to the extent of the providedItem
object(s).Parameter
Description
item
The item at which you want to zoom your map to. This can be a single or a list of
Item
,Layer
,DataFrame
,FeatureSet
, orFeatureCollection
objects.options
Optional set of arguments.
-