Select to view content in your preferred language

Change portalItem id for an existing FeatureLayer

427
2
Jump to solution
11-08-2022 01:08 PM
DanFrey1
New Contributor

In my 2D app, I have created a feature layer that references an ArcGIS Online portal item ID. It works great. I have configured my feature layer with all of the properties that I want. On AGOL, I've got more items that are very similar. The user only needs to see one at a time in the app. I thought "my feature layer works great, all I've got to do is, based on user input, update the portalItem property, and maybe refresh() or load() to display the layer using its new source". This does not seem to work. I just keep getting the original geography.

Am I missing something in thinking I could just update the portalItem id property? If each FeatureLayer has to be created fresh with its own portal id, then what is the most concise way to create like 20 analagous feature layers with identical properties except for a different portal item reference?

0 Kudos
1 Solution

Accepted Solutions
UndralBatsukh
Esri Regular Contributor

Hi there, 

You cannot do that! The source of the layer cannot be changed once the layer is loaded. You have to create new FeatureLayers for each portalItem! You can then toggle the layer visibilities to show only one layer at a time.

View solution in original post

0 Kudos
2 Replies
UndralBatsukh
Esri Regular Contributor

Hi there, 

You cannot do that! The source of the layer cannot be changed once the layer is loaded. You have to create new FeatureLayers for each portalItem! You can then toggle the layer visibilities to show only one layer at a time.

0 Kudos
DanFrey1
New Contributor

That then is what I'll do. Thanks for the confirmation!

0 Kudos