Select to view content in your preferred language

WebMap to Map functionality is broken

2042
20
11-26-2024 07:54 AM
OrvilleMcLean
Emerging Contributor

I have to change my script for downloading feature layers from webmaps from AGOL due to the most recent update in September 2024 which changed the arcgis.mapping and arcgis.widgets into a new arcgis.map module. As a result it also changed the function WebMap() to Map() and this is where my error lies.

I am following the steps in this link and this link but neither are working. I have tried to search for my webmap by name and by id and input it to the new functionality of Map(item=my_result) but everytime I do, I get a huge result of errors. I can post the entire file is needed. Can anyone help with what I am doing wrong or what the new methodology is please?

pydantic_core._pydantic_core.ValidationError: 568 validation errors for Webmap

Here is some of the outputs for the error list, the list goes on for 1715 lines.

webmapobj = Map(item=wm_result1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\map\map_widget.py", line 254, in __init__
self._setup_webmap_properties(item)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\map\map_widget.py", line 402, in _setup_webmap_properties
self._webmap = ws.Webmap(**data)
^^^^^^^^^^^^^^^^^
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\pydantic\main.py", line 164, in __init__
__pydantic_self__.__pydantic_validator__.validate_python(data, self_instance=__pydantic_self__)
pydantic_core._pydantic_core.ValidationError: 568 validation errors for Webmap
operationalLayers.1.AnnotationLayerArcGISAnnotationLayer.layerDefinition.drawingInfo.renderer
Field required [type=missing, input_value={'labelingInfo': [{'label...fset': 0, 'angle': 0}}]}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.4/v/missing
operationalLayers.1.AnnotationLayerArcGISAnnotationLayer.layerType
Input should be 'ArcGISAnnotationLayer' [type=literal_error, input_value='ArcGISFeatureLayer', input_type=str]
For further information visit https://errors.pydantic.dev/2.4/v/literal_error
operationalLayers.1.CatalogLayerCatalogLayer.layerDefinition.drawingInfo.renderer
Field required [type=missing, input_value={'labelingInfo': [{'label...fset': 0, 'angle': 0}}]}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.4/v/missing
operationalLayers.1.CatalogLayerCatalogLayer.layerType
Input should be 'CatalogLayer' [type=literal_error, input_value='ArcGISFeatureLayer', input_type=str]
For further information visit https://errors.pydantic.dev/2.4/v/literal_error
operationalLayers.1.CSVLayerCSV.layerDefinition.drawingInfo.renderer
Field required [type=missing, input_value={'labelingInfo': [{'label...fset': 0, 'angle': 0}}]}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.4/v/missing
operationalLayers.1.CSVLayerCSV.layerType
Input should be 'CSV' [type=literal_error, input_value='ArcGISFeatureLayer', input_type=str]
For further information visit https://errors.pydantic.dev/2.4/v/literal_error
operationalLayers.1.DimensionLayerArcGISDimensionLayer.layerDefinition.drawingInfo.renderer
Field required [type=missing, input_value={'labelingInfo': [{'label...fset': 0, 'angle': 0}}]}, input_type=dict]

Tags (2)
0 Kudos
20 Replies
CameronMcCormick
Regular Contributor

We're having the same issue with certain webmaps, all the ones we have the issue with are in ArcGIS Online.

Just to try something:  I saved a copy of the webmap and then:

  • Tried the Map() and it failed with validation errors
  • Cleared all the layers out of the copy of the webmap
    • Map() worked!
  • Added the feature layers back in individually
    • Map() worked!
  • Turned labels on to start rematching to the original webmap
    • Map() failed!
  • Deleted labels, and disabled them to get back to no labels in the webmap
    • Map() failed!
  • Went into the ArcGIS Assistant and deleted the layerDefinition that was still present in each of the feature layers called in the webmap JSON
    • Map() worked!

 

            "layerDefinition": {
                "drawingInfo": {
                    "labelingInfo": []
                }
            },​

 

 I don't have any other evidence other than it seems to have something to do with the labels in the JSON.

Maybe that helps?!?

JakeSkinner
Esri Esteemed Contributor

Great find @CameronMcCormick !  Looks like this is a bug when label's are enabled.  I was able to reproduce this as well.

0 Kudos
MaureenHaining
Emerging Contributor

Would this bug also explain the similar error I get when converting a webmap to a Map() object when the webmap has a group layer.  If I remove the Group Layer the Map() object is successfully created. I have also tried this without the Building Data Final layer and just the Group Layer for the 2 feature layers.

MaureenHaining_0-1734370272042.png

 

Error.message = 1 validation error for Webmap
applicationProperties.viewing.search.disablePlaceFinder
Field required [type=missing, input_value={'enabled': True, 'layers...sriFieldTypeInteger'}}]}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.8/v/missing
Error.message = 1 validation error for Webmap
applicationProperties.viewing.search.disablePlaceFinder
Field required [type=missing, input_value={'enabled': True, 'layers...sriFieldTypeInteger'}}]}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.8/v/missing
Traceback (most recent call last):
File "C:\Users\mhaining\Documents\Repos\Facilities\facilities-gis-integration\lib\log_utils.py", line 66, in step
return action(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\mhaining\Documents\Repos\Facilities\facilities-gis-integration\Pipelines\extractor.py", line 96, in extract
return self.get_feature_layer()
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\mhaining\Documents\Repos\Facilities\facilities-gis-integration\lib\log_utils.py", line 54, in do_step
return ls.step(name, fn, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\mhaining\Documents\Repos\Facilities\facilities-gis-integration\lib\log_utils.py", line 66, in step
return action(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\mhaining\Documents\Repos\Facilities\facilities-gis-integration\Pipelines\extractor.py", line 75, in get_feature_layer
webmap_obj = Map(self._web_map[0])
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\mhaining\AppData\Local\anaconda3\envs\arcgis240\Lib\site-packages\arcgis\map\map_widget.py", line 254, in __init__
self._setup_webmap_properties(item)
File "C:\Users\mhaining\AppData\Local\anaconda3\envs\arcgis240\Lib\site-packages\arcgis\map\map_widget.py", line 402, in _setup_webmap_properties
self._webmap = ws.Webmap(**data)
^^^^^^^^^^^^^^^^^
File "C:\Users\mhaining\AppData\Local\anaconda3\envs\arcgis240\Lib\site-packages\pydantic\main.py", line 193, in __init__
self.__pydantic_validator__.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 1 validation error for Webmap
applicationProperties.viewing.search.disablePlaceFinder
Field required [type=missing, input_value={'enabled': True, 'layers...sriFieldTypeInteger'}}]}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.8/v/missing
python-BaseException

0 Kudos
GarrettBoucher
New Contributor

Is there a bug report for this, or any idea on when a fix will be implemented? I am running into this issue as well. Removing labels from the map is not an option, making the whole API unusable.

0 Kudos
HayesBuchanan
Emerging Contributor

@CameronMcCormick Just to clarify, did you delete the entire contents of

 "layerDefinition": {}

or just 

"labelingInfo": []

I've disabled labels on all my layers, duplicated the webmap, and deleted the contents of labelingInfo in Arcgis Assistant, but I'm hesitant to take that next step of deleting all of layerDefinition.

Can we get an update on this? @JakeSkinner Having to delete the layer definition for every layer in a web map in order to get this module to work is exceedingly cumbersome.

 

Thanks!

0 Kudos
CameronMcCormick_HRSD
New Contributor

It's been a hot minute since I did this, but if I remember correctly, once that the "labelingInfo" was in the JSON, it became broken until removed, not just turned off in the webmap.  

Unfortunately, when I just recreated the issue, your first example was the only way I could get it to work again...

            "layerDefinition": {},

Though you can Ctrl+Z through the editor in AGO Assistant, definitely make a copy of the JSON before attempting to edit 😎

0 Kudos
CameronMcCormick
Regular Contributor

Sorry, I was logged into my AGO account by accident, that is the same person as me 😵

0 Kudos
Stefan_Thorn
Frequent Contributor

Running from (just recently installed, Python 3.11.10 (main, Sep 20 2024, 18:44:55) ) ArcGIS Pro 3.4 giving the same issue. Try to list all (sub)layers from a webmap via notebook script.

Do not want to rebuild the webmap or need to go into assistant 

 

from arcgis.gis import GIS
# from arcgis.mapping import WebMap
from arcgis.map import Map
gis = GIS('pro')# if running this from Notebook for ArcGIS in AGOL/Enterprise, replace this line with gis = GIS('home')
wmItemId = "?????????????" #put the id of the webmap in here <webmap name>
wmItem = gis.content.get(wmItemId)
# wm = WebMap(wmItem)
wm = Map(wmItem)
for lyr in wm.layers:
print(lyr.title)
try:
for sublyr in reversed(lyr.layers):
print(lyr.title, "|", sublyr.title)
try:
for subsublyr in reversed(sublyr.layers):
print(sublyr.title, "||", subsublyr.title)
except:
fout = True
except:
fout = True

0 Kudos
DebSF
by
Regular Contributor

I'm getting the same issue too - trying to update my ArcGIS API for Python Notebook script and for one of the maps I'm getting 38 errors. Do I need to log a bug with Esri for this?

0 Kudos
KevinS
by
Occasional Contributor

I had this issue as well.  Really a head scratcher, but after reading the output  message and then looking at the web map specification, i realized it was a difference of Vector Symbols vs. Basic. 

I changed everything to Basic symbols FROM vector and BOOOM!  Maps could export with labels!

 

Hope that gets you back on track, it did for me.

-Kevin

0 Kudos