Select to view content in your preferred language

Get Web Map Layer by title removed in 2.4.0, bring it back!!

1231
8
10-08-2024 07:50 AM
Status: Open
Labels (2)
Clubdebambos
MVP Regular Contributor

In the API version 2.3.X and lower there was a lovely WebMap object method called get_layer() that allowed you to retrieve the layer definition using a title parameter and supplying in the name of the layer as a string. See the docs here.

With 2.4.0 this neat functionality has been removed. We now access the layer via m.content.layers[index_position], which means I need to know the index of the layer in the first place. I now have to write a custom method to get the layer of interest based on the title!

Please reinstate this functionality and bring back a way for us to get the WebMap (Map) layer by the layer title!

8 Comments
NanaeAubry

Thanks for posting this. When making such a big shift it's difficult to gauge the importance of certain methods and properties that were previously available.

Since a lot of methods now rely on layer index we will make a method that allows you to get the layer and the index of said layer more easily.

Geraldine

Yes please, bring this back!

jkarmon

I second this! Any word on when this will be resurrected?

BBarbs
by

I'd also like to add my voice to bring this feature back!

RichardHowe

Why would you remove this? Please bring it back

NanaeAubry

Hello everyone,

 

Thank you for adding your voices to this. At version 2.4.1 of the API we have brought back the `get_layer` and `get_table` methods so you can search by title.

 

To make layer indexing better as well we added two new methods called: `layer_info` and `table_info`

You can call them like this: 

```

m = Map()

m.content.layer_info()

```

 

This will return a dataframe of the layers, their index, and some other info.

 

Hope this helps!

RichardHowe

@NanaeAubry Excellent!

Clubdebambos

Hi @NanaeAubry,

Unfortunately this is not what the get_layer() functionality used to be. This function now returns a FeatureLayer object, which is pretty useless when dealing with WebMaps, instead of the layer definition (Dict/JSON). We can create a FeatureLayer object from the url in the layer definition if needs be. Returning a FeaturLayer object from the get_layer() for a WebMap offers no advantage when you want to get/manipulate/update the layer JSON definition, which is what I expect most workflows would entail.

Maybe another method called get_layer_def() perhaps?

All the best,

Glen