Select to view content in your preferred language

How to load a wms layer to an existing webmap

970
1
01-30-2020 05:09 AM
Arpa_PiemonteGeoportal_Team
Frequent Contributor

Dear Community,

I am trying to add a wms to a an existing webmap on agol. While I am able to add a feature layer, I can't do with a wms one. It raises the following error:

KeyError                                  Traceback (most recent call last)C:\Users\gabrnico\AppData\Local\Continuum\anaconda2\envs\deep_learn_arcgis\lib\site-packages\arcgis\gis\__init__.py in __getitem__(self, k)   6397         try:-> 6398             return dict.__getitem__(self, k)   6399         except KeyError:KeyError: 'layers'  During handling of the above exception, another exception occurred: KeyError                                  Traceback (most recent call last)<ipython-input-265-26187b331006> in <module>      4 #      5 #----> 6 my_webmap.add_layer(my_layer_bdtre,options={'title':'layer bdtre '})      7 

Below the code I am running:

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

gis = GIS("https://www.arcgis.com/", "my_user", "mypass", verify_cert=True)

my_layer_bdtre = gis.content.get('my_item_id') # this is a wms item

my_map = gis.content.get('my_map_id')  #  this is a webmap previously prepared

my_webmap = WebMap(my_map)

my_webmap.add_layer(my_layer_bdtre,options={'title':'layer bdtre '}) 

the wms item was creted as follows:

my_url_bdtre = "https://geomap.reteunitaria.piemonte.it/ws/taims/rp-01/taimswms/bdtre_idro?service=WMS&SR=4326&request=getCapabilities"


item_bdtre={
'title':'BDTRE ',
'description':'Test WMS bdtre',
'tags':'_WMS, bdtre',
'type':'WMS',
'url':my_urlb_dtre}

item_wms_bdtre = gis.content.add(item_properties=item_bdtre,  folder='_SVILUPPO')

Any help would be much appreciated

Kind regards

Gabriele

1 Reply
Sabina
by
Occasional Contributor

I have the same problem

0 Kudos