Select to view content in your preferred language

How to transfer symbology and filters from one layer to another in a webmap in AGOL

224
2
3 weeks ago
SanchezNuñez
Frequent Contributor

Good morning,

I am looking for a way to transfer the symbology and filter for an existing layer to a new layer I just added to a map.  Is there a way to do that or do I have to re-doit in the new layer.

Thanks

0 Kudos
2 Replies
RussRoberts
Esri Notable Contributor

There is currently not possible in Map Viewer. It is on our roadmap to support this behavior. For now if you have access to Pro you can open the web map and copy the original layer and on the new layer you will see Paste Properties where you can apply the symbology. For the filter you could take the SQL of the first layer and paste it into the second layers definition expression sql editor. 

RussRoberts_0-1765554416902.png

 

JohnEvans6
Frequent Contributor

Update: I assumed you have identical layers with different data like I did. If they're not the same I wouldn't go anywhere near this.

With the caveat being "it's probably faster and easier to do this in pro", I set up a real short notebook to update the symbology of a layer years ago when I had this problem. I will say now that I am catching up the documentation this doesn't seem to be encouraged so your mileage may vary.

from arcgis.gis import GIS
gis = GIS("home")

# Template (fill in id)
template_id = ''

# To Update (fill in id)
layer_to_update_id = ''

#Get template item
template_item = gis.content.get(template_id)

# Get layers were updating
template_layers = template_item.layers

#Get item were updating
to_update_item = gis.content.get(layer_to_update_id)

# Which layer gets the symbology?
to_update_layers = to_update_item.layers

# In this example I am just taking the first template layer and updating the first to update layer, which is what [0] is for (just get the first item in each list)
to_update_layers[0].manager.update_definition({"drawingInfo": template_layers[0].properties['drawingInfo']})

# Verify update
sample_display = gis.map('USA')
sample_display.basemap.basemap = 'dark-gray-vector'

sample_display.content.add(to_update_layers[0])
 
#Verify the symbology has been applied to the layer.
sample_display

I can't for the life of me find how you would apply a filter based on the documentation. I kind of figured it would be similar to this or that there would be a new method or property you could update, but I'm coming up short.

0 Kudos