MapContent class move() method does not move a layer into a GroupLayer and errors
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Start in arcgis/map/map_widget.py at the MapContent.move() method around line 2794, then reproduce the issue with the provided Map, GroupLayer, and layer setup. Done means the script runs without AttributeError and the selected layer is moved into the existing group layer.
Written by the indexing model from the issue text.
Description
Describe the bug
The Map class content property is a MapContent object that has a move() method as per documentation here to move a layer into an existing GroupLayer’s list of layers. However, this has never worked since its introduction in version 2.4.0.
To Reproduce
Steps to reproduce the behavior:
Have a WebMap where the top layer is a group layer and the bottom is a normal layer. Or alter the indexes below to suit.
from arcgis.gis import GIS
from arcgis.map import Map
## Access AGOL
agol = GIS("home")
## Access the WebMap Item
wm_item = agol.content.get("WM_ITEM_ID")
## Create a Map object from WebMap Item
webmap = Map(wm_item)
## Get the GroupLayer object
gl = webmap.content.layers[1]
## move to group
webmap.content.move(
index=0,
group=gl
)
## update the webmap
webmap.update()
error:
Traceback (most recent call last):
File "<module1>", line 17, in <module>
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\map\map_widget.py", line 2794, in move
group._layer.layers.append(pydantic_layer)
^^^^^^^^^^^^
AttributeError: 'GroupLayer' object has no attribute '_layer'. Did you mean: 'layers'?
Screenshots
N/A
Expected behavior
The script runs without error and the layer is moved into the group layer. Although it is not clear if the layer will be added to the top or bottom of the layers in the group layer.
Platform (please complete the following information):
- OS: Windows 11
- Browser: Chrome/Edge
- Python API Version: 2.4.0, 2.4.2, 2.4.3
Additional context
Add any other context about the problem here, attachments etc.
- Dominant language
- Python
- Stars
- 2.2k
- Forks
- 1.1k
- Avg merge
- 2h 40m
- Merged PRs (30d)
- 2
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Esri/arcgis-python-api
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 85/100
Esri/arcgis-python-api#2453 · 3 comments ·
-
documentation enhancement
Difficulty 1/5 Under an hour Newbie friendliness 76/100
Esri/arcgis-python-api#2097 · 1 comment ·
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 58/100
Esri/arcgis-python-api#2537 · 3 comments ·
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 56/100
Esri/arcgis-python-api#2531 · 1 comment ·
-
bug
Esri/arcgis-python-api#2527 · 4 comments · 1 assignee ·
All issues in Esri/arcgis-python-api
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100