List all feature layers from portal

231
2
Jump to solution
03-14-2024 07:09 AM
padmalcom
Occasional Contributor

Hi, we'd like to list all available feature layers that are available in ArcGIS portal. Our assumption was that there exists something like:

 

val portal = Portal(PORTAL_URL, Portal.Connection.Anonymous)
portal.fetchFeatureLayers()
...

But none of the "fetch..." methods returns the feature layer we created in ArcGIS portal.

Edit: After digging a bit more into the issue, we found out that none of the (vector) basemaps from our portal are fetched. Instead we receive items with names such as:

- 0330_Dark_Gray_Canvas_Title

- 0310_Terrain_Labels_Title

- 0120_Imagery_Hybrid_Title

- ...

Do you have any expaination why our basemaps are not listed by the fetch* command?

Thanks in advance

0 Kudos
1 Solution

Accepted Solutions
Erick_1
Esri Contributor

Hello @padmalcom ,

We provide the Portal.findItems(PortalQueryParameters) API to find items of a specific type.

In your PortalQueryParameters, you can specify the Portal item type you wish to search for.

For example, If I want to search for all Feature Service/Feature Layer owned by the Portal's user then you could do something like this: 

 

val portalQueryParameters = PortalQueryParameters(query = "type:Feature Service AND owner:${portal.user?.username}", limit = 100) 
val portalQueryResultSet = portal.findItems(portalQueryParameters).getOrNull()

 

After that, all the desired items should be in the PortalQueryResultSet returned.

Here's a list of the supported types: https://developers.arcgis.com/rest/users-groups-and-items/items-and-item-types.htm

You can find more about the search query here: https://developers.arcgis.com/rest/users-groups-and-items/search-reference.htm

Regarding your Basemap question,

I assume you're referring to the following APIs:

 

 

Portal.fetchBasemaps()
----
Portal.fetchVectorBasemaps()

 

 

After getting the result, you have to load each Basemap in order to inspect the layers.

Let me know if this resolves your question.

 

View solution in original post

0 Kudos
2 Replies
Erick_1
Esri Contributor

Hello @padmalcom ,

We provide the Portal.findItems(PortalQueryParameters) API to find items of a specific type.

In your PortalQueryParameters, you can specify the Portal item type you wish to search for.

For example, If I want to search for all Feature Service/Feature Layer owned by the Portal's user then you could do something like this: 

 

val portalQueryParameters = PortalQueryParameters(query = "type:Feature Service AND owner:${portal.user?.username}", limit = 100) 
val portalQueryResultSet = portal.findItems(portalQueryParameters).getOrNull()

 

After that, all the desired items should be in the PortalQueryResultSet returned.

Here's a list of the supported types: https://developers.arcgis.com/rest/users-groups-and-items/items-and-item-types.htm

You can find more about the search query here: https://developers.arcgis.com/rest/users-groups-and-items/search-reference.htm

Regarding your Basemap question,

I assume you're referring to the following APIs:

 

 

Portal.fetchBasemaps()
----
Portal.fetchVectorBasemaps()

 

 

After getting the result, you have to load each Basemap in order to inspect the layers.

Let me know if this resolves your question.

 

0 Kudos
padmalcom
Occasional Contributor

Thanks @Erick_1, we organized the basemaps and features in groups and use the Portal Queries as proposed which is much cleaner since we can organize our content much better. Thank you furthermore for the explaination why fetchBasemaps() and fetchVectorBasemaps() only work when loaded - we actually didn't load them.

0 Kudos