當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python ArcGIS WebMap.update用法及代碼示例

本文簡要介紹 python 語言中 arcgis.mapping.WebMap.update 的用法。

用法:

update(item_properties=None, thumbnail=None, metadata=None)

返回:

指示成功 (True) 或失敗 (False) 的布爾值。

update 方法使用您對WebMap 對象所做的更改來更新 GIS 中的Web Map項。此外,您可以更新其他項目屬性、縮略圖和元數據。

注意:

如果您從現有 web Map項的 WebMap 對象開始,則調用此方法將使用您的更改更新該項目。

如果您開始使用新的 WebMap 對象(沒有 Web Map項),則調用此方法將引發 RuntimeError 異常。如果要將 WebMap 對象保存到新的 web Map項目中,請改為調用 save 方法。

對於 item_properties ,傳入要更新的屬性的參數。所有其他屬性將保持不變。例如,如果您隻想更新項目的說明,則隻需在 item_properties 中提供說明參數。

Parameter

Description

item_properties

可選字典。有關鍵和值,請參見下表。

thumbnail

可選字符串。縮略圖的路徑或 URL。

metadata

可選字符串。元數據的路徑或 URL。

參數item_properties的鍵:值字典選項

Key

Value

typeKeywords

可選字符串。提供所有 sub-types 的列表,請參閱下麵的 URL 1 以獲取有效值。

description

可選字符串。項目的說明。

title

可選字符串。項目的名稱標簽。

tags

可選字符串。以逗號分隔值或字符串列表形式列出的標簽。用於搜索項目。

snippet

可選字符串。提供項目內容的簡短摘要(最多 250 個字符)。

accessInformation

可選字符串。有關內容來源的信息。

licenseInfo

可選字符串。有關內容的任何許可信息或限製。

culture

可選字符串。地區、國家和語言信息。

access

可選字符串。有效值為 private、shared、org 或 public。

commentsEnabled

可選的布爾值。默認為 true,控製評論是允許 (true) 還是不允許 (false)。

以上是您設置的最常見的項目屬性(元數據)。要獲取完整列表,請參閱 ArcGIS REST API 文檔中的 common parameters 頁麵。

例子:

# USAGE EXAMPLE 1: Update an existing web map

from arcgis.gis import GIS
from arcgis.mapping import WebMap

# log into your GIS
gis = GIS(url, username, password)

# edit web map by adding, removing, editing layers and basemaps
wm = WebMap()  # new web map
wm.add_layer(...)  # add some layers

# save the web map
webmap_item_properties = {'title':'Ebola incidents and facilities',
             'snippet':'Map created using Python API showing locations of Ebola treatment centers',
             'tags':['automation', 'ebola', 'world health', 'python']}

new_wm_item = wm.save(webmap_item_properties, thumbnail='./webmap_thumbnail.png')

# to visit the web map using a browser
print(new_wm_item.homepage)
>> 'https://your portal url.com/webadaptor/item.html?id=1234abcd...'

相關用法


注:本文由純淨天空篩選整理自arcgis.com大神的英文原創作品 arcgis.mapping.WebMap.update。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。