PortalItem

@Serializable(with = PortalItemSerializer::class)
class PortalItem : Item, JsonSerializable, Loadable

An item (unit of content) stored in an ArcGIS portal, such as a layer, web map, package file, or map service. ArcGIS portals support various types of portal items, including:

  • Web maps and scenes.

  • Services such as feature, map, scene, image, and OGC services that can be added as layers to a map.

  • Data files that can be uploaded, stored, and downloaded, such as .mmpk or .vtpk files.

  • Applications and tools.

Each portal item contains information about the item such as its unique ID, the owning Portal, and the type of item it is (PortalItemType). Portal items can be kept private to the users that created them, shared with other users in specific groups, or made public and accessible to everyone.

You can use the portal item ID along with a portal URL to quickly instantiate a new portal item object. The item's details page has the following URL formats: http://www.arcgis.com/home/item.html?id=[itemId]. If your portal item is a web map, you can also obtain a URL with the format: https://www.arcgis.com/home/webmap/viewer.html?webmap=[itemId] from the ArcGIS Online Map Viewer. In both cases, you can use the itemId as the ID to instantiate a portal item.

Alternatively, you can obtain a portal item directly from a portal using a method such as Portal.findItems(PortalQueryParameters).

Since

200.0.0

See also

Constructors

Link copied to clipboard
constructor(portal: Portal, type: PortalItemType)

Creates a new portal item object with the specified type in the specified portal. Use this constructor if you wish to create a new a PortalItem to add to a portal.

constructor(portal: Portal, itemId: String)

Creates a portal item object using the specified portal and item ID. The portal item ID can be determined from the URL of the item details web page or the ArcGIS Online map viewer and scene viewer web applications in your portal. The item details page has the following format https://www.arcgis.com/home/item.html?id=[itemId]. The map viewer has the format https://www.arcgis.com/home/webmap/viewer.html?webmap=[itemId] or https://www.arcgis.com/apps/mapviewer/index.html?webmap=[itemId] depending on whether you use the classic map viewer or the new map viewer. The scene viewer has the following format https://www.arcgis.com/home/webscene/viewer.html?webscene=[itemId]. In all cases, you can use the itemId as the ID to instantiate a portal item.

constructor(url: String)

Creates a portal item from the specified portal item URL. Use this object to create a portal item from a URL. The supported URL formats are:

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard

The average rating of this portal item.

Link copied to clipboard

The number of comments on this portal item.

Link copied to clipboard

True if the comments are allowed on the portal item, false otherwise. Will return false if an error occurs.

Link copied to clipboard

The culture (language and country) of the portal item.

Link copied to clipboard

The ID of the folder in which the owner has stored the item. The property is only returned to users who are the item's owner or the org admin. A null folderID means either an error or that the folderID is unknown to the user. An empty folderID means that the item is stored at the root folder of the user directory.

Link copied to clipboard

The username of the user who owns this portal item.

Link copied to clipboard

The ArcGIS portal that contains this portal item.

Link copied to clipboard

The number of ratings on the portal item.

Link copied to clipboard

The URL of the service that this portal item represents. This only applies to portal items that represent web-accessible resources such as map services. Will return null if an error occurs and an empty string if the item doesn't represent a web-accessible resource.

Link copied to clipboard
val size: Long

The size of this portal item. Will return -1 if an error occurs.

Link copied to clipboard

The GIS content type of this portal item. A portal item's type cannot be changed once it has an item ID. If you wish to change the type you must create a new PortalItem.

Link copied to clipboard

The type name of this portal item. Most generally the type name is the string representation of the PortalItemType returned by PortalItem.type. However if the type is PortalItemType.Unknown, the type name is set with the type found in the portal item JSON. This allows API to deal with new portal item types added since the latest API release.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val url: String

The URL of this portal item.

Link copied to clipboard

The number of views of this portal item. Will return -1 if an error occurs.

Inherited properties

Link copied to clipboard

The information on the source of the item and its copyright status.

Link copied to clipboard

The date the item was created.

Link copied to clipboard

The description of the specified item.

Link copied to clipboard

The extent of the specified item.

Link copied to clipboard

The item ID of the specified item. Item ID can only be set on not loaded item.

Link copied to clipboard
open override val loadStatus: StateFlow<LoadStatus>

The load status.

Link copied to clipboard

The date the item was last modified.

Link copied to clipboard

The name of this item.

Link copied to clipboard

The short summary description of the specified item. A short summary description of the item.

Link copied to clipboard

The spatial reference name of the specified item. The coordinate system of the specified item.

Link copied to clipboard

The user defined tags that describe the specified item.

Link copied to clipboard

The terms of use of the item. It is stored in the "licenseInfo" property in json. The property can contain HTML markup.

Link copied to clipboard

The thumbnail of the item.

Link copied to clipboard

The title of the specified item. This is the name that's displayed to users and by which they refer to the item. Every item must have a title.

Link copied to clipboard

An array of keywords that further describes the type of this item. Each item is tagged with a set of type keywords that are derived based on its primary type. The type keywords of the specified item.

Functions

Link copied to clipboard
suspend fun addComment(comment: String): Result<Unit>

Adds a comment to a portal item that the user has access to. This method is only available to authenticated users.

Link copied to clipboard
suspend fun addRating(rating: Float): Result<Unit>

Adds a rating to a portal item that the user has access to. Only one rating can be given to a portal item per user. If this call is made on an already rated portal item, the new rating will overwrite the current one. A user cannot rate their own portal item. This method is only available to authenticated users.

Link copied to clipboard

Fetches the comments for the portal item that you have access to. This method is only available to authenticated users.

Link copied to clipboard

Fetches the groups this portal item belongs to. Only those groups that are visible to the current portal user will be returned.

Link copied to clipboard

Fetches all related portal items with the specified relationship to this portal item.

Fetches all related portal items with any of the specified relationships to this portal item.

Link copied to clipboard
suspend fun shareWith(everyone: Boolean, organization: Boolean = false): Result<Unit>

Shares this portal item with everyone or just with the user's organization. This method is only available to authenticated users. If both 'everyone' and 'organization' are true, the portal item will be shared with everyone (Public). If both 'everyone' and 'organization' are false, the portal item will be made private, unless the item has been shared with one or more groups. In that case, the items access property will be set to PortalAccess.Shared. The groups an item has been shared with are not affected by this method.

Link copied to clipboard

Shares this portal item with the specified portal groups. This method is only available to authenticated users. The portal groups are added to the existing set of portal groups the item is shared with. The result of this method is an unmodifiable collection of portal groups, one for each group with which the item could not be shared. It is empty if all groups were shared with successfully. It is not necessary to load the PortalGroup objects that are passed to this method.

Link copied to clipboard
suspend fun unshare(): Result<Unit>

Stops all sharing of this portal item. This sets the access property of the item to PortalAccess.Private and makes the item accessible to only the item owner. Removes all groups from the set of groups the item is shared with.

Link copied to clipboard

Stops sharing this portal item with the specified collection of portal groups. The collection of groups are removed from the set of groups the item is shared with. The result is an unmodifiable collection of portal groups, one for each group for which the item could not be unshared, empty if all groups were unshared with successfully. It is not necessary to load the PortalGroup objects that are passed to this method.

Link copied to clipboard
suspend fun updateContent(contentParameters: PortalItemContentParameters): Result<Unit>

Update the portal item with the given PortalItemContentParameters.

Link copied to clipboard
open suspend override fun updateItemProperties(): Result<Unit>

Executes an asynchronous operation to update any item properties that have been changed (using the setter methods). This causes the values that have been changed to be updated on the portal (for PortalItems) or on disk (for LocalItems).

Inherited functions

Link copied to clipboard
open override fun cancelLoad()

Cancels loading metadata for the Loadable object.

Link copied to clipboard
suspend fun fetchData(): Result<ByteArray>

Fetches the item's data.

Link copied to clipboard
open suspend override fun load(): Result<Unit>

Loads the metadata for the object.

Link copied to clipboard
open suspend override fun retryLoad(): Result<Unit>

Loads or retries loading metadata for the object.

Link copied to clipboard

Sets the thumbnail of the item with the specified image. This method invokes Bitmap.compress and may be long running.

Link copied to clipboard
open override fun toJson(): String

Convert an object to JSON string.