Esri / Esri/arcgis-python-api

MapContent class move() method does not move a layer into a GroupLayer and errors

Aperta Adatta ai principianti
#2,513 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
bug
Lingua principale
Python
Stelle
2.2k
Fork
1.2k
Merge medio
2h 40m
PR unite (30g)
2

Descrizione

**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.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
api
Tipo di issue
Bug
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Attiva
Chiarezza
Specificata chiaramente
Idoneità per principianti
78/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.