Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't load Web Maps or Feature Layers #2197

Open
torbenal opened this issue Jan 15, 2025 · 1 comment
Open

Can't load Web Maps or Feature Layers #2197

torbenal opened this issue Jan 15, 2025 · 1 comment

Comments

@torbenal
Copy link

Hello!

I'm working with the arcgis API for Python, but I'm having some serious issues getting it to work as expected.

I'm using portal-tier authentication.

First I try loading a Web Map directly. That gives me the following error.

from arcgis.gis import GIS

portal = GIS(url="https://maps.xyz.com/portal", username="xyz", password="xyz")
web_map_id = 'xyz'
web_map = portal.content.get(web_map_id)
portal.map(web_map)

============
ValidationError: 3680 validation errors for Webmap
operationalLayers.5.AnnotationLayerArcGISAnnotationLayer.layerType
  Input should be 'ArcGISAnnotationLayer' [type=literal_error, input_value='ArcGISMapServiceLayer', input_type=str]
    For further information visit https://errors.pydantic.dev/2.4/v/literal_error
operationalLayers.5.CatalogLayerCatalogLayer.layerType
  Input should be 'CatalogLayer' [type=literal_error, input_value='ArcGISMapServiceLayer', input_type=str]
    For further information visit https://errors.pydantic.dev/2.4/v/literal_error
operationalLayers.5.CSVLayerCSV.layerType
  Input should be 'CSV' [type=literal_error, input_value='ArcGISMapServiceLayer', input_type=str]
    For further information visit https://errors.pydantic.dev/2.4/v/literal_error
operationalLayers.5.DimensionLayerArcGISDimensionLayer.layerType
...
  Field required [type=missing, input_value={'id': 911, 'layerDefinit...efaultVisibility': True}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.4/v/missing
operationalLayers.5.LinkChartLayerLinkChartLayer.layerType
  Input should be 'LinkChartLayer' [type=literal_error, input_value='ArcGISMapServiceLayer', input_type=str]
    For further information visit https://errors.pydantic.dev/2.4/v/literal_error

Subsequently, I tried starting with an empty map, and loading Feature Layers directly

from arcgis.layers import Service

layers = Service(
    "https://xyz.com/arcgis/rest/services/xyz/xyz/FeatureServer"
)
m = portal.map()
m.basemap.basemap = 'satellite'

for lyr in layers.layers:
    m.content.add(lyr)

m.center = [xyz, xyz]
m.zoom = 30

That just outputs the basemap, with no layers to be seen.

Printing layers gives the following

<FeatureLayerCollection url:"https://xyz.com/arcgis/rest/services/xyz/xyz/FeatureServer">

Is this maybe a permission issue? I have no other ideas left. I've followed the guides in the documentation.
Also, this is all on version 2.4.0

Cheers.

@nanaeaubry
Copy link
Contributor

@torbenal
Some maps have issues with our new class but we have fixed that for the next release. Are there special layer types in this map?

For the layer what type of layer are you trying to add? Rather than iterate through, try to add the entire service and see if that works.

lyr = Service("url")
map.content.add(lyr)

Another thing to check is the spatial reference of the layers vs the spatial reference of the map.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants