arcgis.widgets module¶
The arcgis.widgets module provides components for visualizing GIS data and analysis. This module includes the MapView Jupyter notebook widget for visualizing maps and layers
MapView¶
-
class
arcgis.widgets.
MapView
(**kwargs)¶ Bases:
ipywidgets.widgets.domwidget.DOMWidget
Mapping widget for Jupyter Notebook
-
add_layer
(item, options=None)¶ Adds the specified layer or item to the map widget.
Argument Description item Required object. You can specify Item objects, Layer objects such as FeatureLayer, ImageryLayer, MapImageLayer etc., FeatureSet and FeatureCollection objects. options Optional dict. Specify visualization options such as renderer info, opacity, definition expressions. See example below
-
basemap
¶ Name of the basemap displayed on the map widget. To change the basemap, simply assign it a different value. You can get the list of all basemap values by calling the basemaps property. :return:
-
basemaps
¶ An instance of a Python list.
-
center
¶ An instance of a Python list.
-
clear_graphics
()¶ Clear the graphics drawn on the map widget. Graphics are shapes drawn using the ‘draw()’ method. :return:
-
draw
(shape, popup=None, symbol=None, attributes=None)¶ Draws a shape on the map widget. You can draw anything from known geometries, coordinate pairs, FeatureSet objects.
-
end_time
¶ A trait for unicode strings.
-
extent
¶
-
gallery_basemaps
¶ Retrieves the portal’s custom basemap group and populates properties
-
id
¶ A trait for unicode strings.
-
layers
¶ The list of layers added to the map widget using the add_layers() method. :return:
-
mode
¶ A trait for unicode strings.
-
on_click
(callback, remove=False)¶ Register a callback to execute when the map is clicked.
The callback will be called with one argument, the clicked widget instance.
- remove : bool (optional)
- Set to true to remove the callback from the list of callbacks.
-
on_draw_end
(callback, remove=False)¶ Register a callback to execute when something is drawn
The callback will be called with two argument, the clicked widget instance, and the geometry drawn
- remove : bool (optional)
- Set to true to remove the callback from the list of callbacks.
-
remove_layers
(layers=None)¶ Removes the layers added to the map widget. You can get the list of layers added to the widget by querying the ‘layers’ property.
Returns: True if layer is successfully removed. Else, False.
-
save
(item_properties, thumbnail=None, metadata=None, owner=None, folder=None)¶ Save the map widget object into a new web map Item in your GIS.
Note
If you started out with a fresh map widget object, use this method to save it as a the web map item in your GIS.
If you started with a map widget object from an existing web map item or WebMap object, calling this method will create a web map new item with your changes. If you want to update the existing web map item with your changes, call the update() method instead.
Argument Description item_properties Required dictionary. See table below for the keys and values. 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 Argument 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. URL 1: http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r3000000ms000000
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' italy_streets_map = map1.save({'title':'Italy streets', 'snippet':'Arterial road network of Italy', 'tags':'streets, network, roads'})
-
set_time_extent
(start_time, end_time)¶
-
start_time
¶ A trait for unicode strings.
-
update
(item_properties=None, thumbnail=None, metadata=None)¶ Updates the web map item that was used to create the MapWidget object. In addition, you can update other item properties, thumbnail and metadata.
Note
If you started out a MapView object from an existing web map item, use this method to update the web map item in your with your changes.
If you started out with a fresh MapView object (without a web map item), calling this method will raise a RuntimeError exception. If you want to save the map widget into a new web map item, call the save() method instead.
For item_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.
Argument Description item_properties Optional dictionary. See table below for the keys and values. 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 Argument 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). URL 1: http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r3000000ms000000
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')
-
width
¶ A trait for unicode strings.
-
zoom
¶ An int trait.
-