Programmatically identifying the hosted featurelayer and featurelayer view

424
2
Jump to solution
08-03-2021 05:27 AM
MayoTestUser
New Contributor II

Hi, I have hosted a feature layer in ArcGIS Online 10.8 and created a feature layer view from the hosted feature layer. I consumed these two as portal items in my webmap application using ESRI JavaScript API 4.19.

It is required to find out which one is the feature layer view from these two portal items through the JavaScript API.

Names will be unique for these layer but however the need is to identify from the property/methods of these layers.

Kindly suggest me. Many thanks in advance!

0 Kudos
1 Solution

Accepted Solutions
BjornSvensson
Esri Regular Contributor

The FeatureLayer.sourceJSON contains all the metadata from the FeatureLayer REST endpoint, including what you need to distinguish between the View Layer and original feature layer.

For example, in this case, the metadata JSON for hosted layer views include a "isView: true".  So you could check for featureLayer.sourceJSON.isView .

https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#sourceJS...
https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/DrinkingWaterOSM_viewlayer/Feature... 

View solution in original post

2 Replies
BjornSvensson
Esri Regular Contributor

The FeatureLayer.sourceJSON contains all the metadata from the FeatureLayer REST endpoint, including what you need to distinguish between the View Layer and original feature layer.

For example, in this case, the metadata JSON for hosted layer views include a "isView: true".  So you could check for featureLayer.sourceJSON.isView .

https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#sourceJS...
https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/DrinkingWaterOSM_viewlayer/Feature... 

MayoTestUser
New Contributor II

Thanks a lot Bjorn. It works well as expected !

0 Kudos