MapContent class move() method does not move a layer into a GroupLayer and errors
- Dominant language
- Python
- Stars
- 2.2k
- Forks
- 1.2k
- Avg merge
- 2h 40m
- Merged PRs (30d)
- 2
Description
**Describe the bug**
The _Map_ class _content_ property is a _MapContent_ object that has a _move()_ method as per documentation [here](https://developers.arcgis.com/python/latest/api-reference/arcgis.map.toc.html#arcgis.map.map_widget.MapContent.move) 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.
```python
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:
```python
Traceback (most recent call last):
File "", line 17, in
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.
Contributor guide
Assessment
This issue has not been assessed yet.