import Portal from "@arcgis/core/portal/Portal.js";const Portal = await $arcgis.import("@arcgis/core/portal/Portal.js");- Inheritance:
- Portal→
Accessor
- Since
- ArcGIS Maps SDK for JavaScript 4.0
The Portal class is part of the ArcGIS Enterprise portal that provides a way to build applications that work with content from ArcGIS Online or an ArcGIS Enterprise portal. ArcGIS Enterprise is software from Esri that customers can deploy either on-premises or in the cloud. ArcGIS Online is Esri's Software as a Service offering that represents GIS as a Service and is implemented using the same technology as ArcGIS Enterprise.
The Portal API allows application developers to work with users, groups and content hosted within ArcGIS Online or within an ArcGIS Enterprise portal. The API allows developers to build web, mobile, and desktop applications that support sharing and collaboration using web maps. Organizational developers can also use the API to build custom applications for their users.
The Portal class provides a view of the portal as seen by the current user, anonymous or logged in. It includes information such as the name, logo, featured items and supported protocols (http vs https) for this portal. If the user is not logged in, this call will return the default view of the portal. If the user is logged in, the view of the portal returned will be specific to the organization that the user belongs to. The default view of the portal is dependent on the culture of the user that is obtained from the users profile.
If no url is set before loading the Portal, the API defaults to that of esriConfig.portalUrl. There may be scenarios when more than one portal instance are needed. In these circumstances, there are a couple of different options to take into account.
- Set a new Portal instance within the PortalItem
and set the portal's url.
Layer.fromPortalItem({portalItem: {id: "e691172598f04ea8881cd2a4adaa45ba",// autocastable to Portalportal: {url: "https://thePortalUrl"}}});
- Create separate portal instances before passing them into the PortalItem's portal property.
let portalA = new Portal({url: "https://www.exampleA.com/arcgis" // First instance});let portalB = new Portal({url: "https://www.exampleB.com/arcgis" // Second instance});let item = new PortalItem({id: "e691172598f04ea8881cd2a4adaa45ba",portal: portalA // This loads the first portal instance set above});item.load();
The when() method on the Portal instance can be called to execute processes that may only run after the Portal is loaded.
// load the Portal and PortalQueryParams modulesconst [Portal, PortalQueryParams] = await $arcgis.import([ "@arcgis/core/portal/Portal.js", "@arcgis/core/portal/PortalQueryParams.js"]);portal = new Portal();// Setting authMode to immediate signs the user in once loadedportal.authMode = "immediate";
// Once portal is loaded, user signed inportal.load().then(function() { console.log(portal);
// Create query parameters for the portal search // This object autocasts as new PortalQueryParams() let queryParams = { query: "owner:" + portal.user.username, sortField: "numViews", sortOrder: "desc", num: 20 }; // Query the items based on the queryParams created from portal above portal.queryItems(queryParams).then(createGallery);});Constructors
Constructor
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| properties | | |
Properties
| Property | Type | Class |
|---|---|---|
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
declaredClass readonly inherited | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
Array<FeaturedGroup> | null | undefined | | |
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
isOrganization readonly | | |
| | ||
| | ||
| | ||
loaded readonly | | |
loadError readonly inherited | ||
loadStatus readonly inherited | "not-loaded" | "loading" | "failed" | "loaded" | |
loadWarnings readonly inherited | any[] | |
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
restUrl readonly | | |
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
thumbnailUrl readonly | | |
| | ||
| | ||
| | ||
| | ||
| | ||
PortalUser | null | undefined | | |
| | ||
| | ||
| |
allSSL
- Type
- boolean
When true, access to the organization's Portal resources must occur over SSL.
- Default value
- false
authMode
- Type
- PortalAuthMode
The authentication mode for handling authentication when the user attempts to access a secure resource.
| Possible Value | Description |
|---|---|
| anonymous | An error will be returned when a secure resource is requested. |
| auto | The user will be signed in when a secure resource is requested. |
| immediate | The user will be signed in when the Portal is loaded. |
| no-prompt | Checks for whether the user is already signed in. If so, no additional prompts display for sign-in. |
- Default value
- "auto"
basemapGalleryGroupQuery
- Since
- ArcGIS Maps SDK for JavaScript 4.4
The query that defines the basemaps that should be displayed in the BasemapGallery when useVectorBasemaps is not true. The fetchBasemaps() method does this automatically.
basemapGalleryGroupQuery3D
- Since
- ArcGIS Maps SDK for JavaScript 4.27
The query that defines the 3D basemaps that should be displayed in the BasemapGallery. The fetchBasemaps() method does this automatically.
canListApps
- Type
- boolean
Indicates whether an organization can list applications in the marketplace.
- Default value
- false
canListData
- Type
- boolean
Indicates whether an organization can list data services in the marketplace.
- Default value
- false
canListPreProvisionedItems
- Type
- boolean
Indicates whether an organization can list pre-provisioned items in the marketplace.
- Default value
- false
canProvisionDirectPurchase
- Type
- boolean
Indicates whether an organization can provision direct purchases in the marketplace without customer request.
- Default value
- false
canSearchPublic
- Type
- boolean
When true, the organization's public items, groups and users are included in search queries.
When false, no public items outside of the organization are included. However,
public items which are part of the organization are included.
- Default value
- true
canShareBingPublic
- Type
- boolean
The Bing key can be shared to the public and is returned as part of a portal's description call (/sharing/rest/portals/<orgid>).
This requires the access of the portal to be set to public. The canShareBingPublic property is not returned publicly but only
shown to users within the organization.
- Default value
- false
canSharePublic
- Type
- boolean
When true, members of the organization can share resources outside the organization.
- Default value
- false
canSignInArcGIS
- Type
- boolean
Indicates whether to allow an organization with an enterprise IDP configured to be able to turn on or off the ArcGIS sign in.
- Default value
- false
canSignInIDP
- Type
- boolean
Indicates whether to allow an organization with an enterprise IDP configured to be able to turn on or off the enterprise sign in.
- Default value
- false
commentsEnabled
- Type
- boolean
Indicates whether to allow the organization to disable commenting. When commentsEnabled is false, comments are hidden and not removed. numComments are set to zero for all items in the organization. Calls to add a comment and view comments will fail. If the organization re-enables comments, the comments display and numComments are restored.
- Default value
- false
default3DBasemapQuery
- Since
- ArcGIS Maps SDK for JavaScript 4.31
The query that defines the default 3d basemap to use in scene views for the portal. The fetchDefault3DBasemap() method uses this to return a basemap object.
devBasemapGalleryGroupQuery
- Since
- ArcGIS Maps SDK for JavaScript 4.22
The query that defines the basemaps that should be displayed in the BasemapGallery when an Config is defined. The fetchBasemaps() method does this automatically.
eueiEnabled
- Since
- ArcGIS Maps SDK for JavaScript 4.7
Boolean value indicating whether to opt-in to the Esri User Experience Improvement (EUEI) program.
featuredGroups
- Type
- Array<FeaturedGroup> | null | undefined
The featured groups for the portal. Returns an array of objects that provide access to the owner and title for each featured group. Each item in this array has the following specification:
g3DTilesGalleryGroupQuery
- Since
- ArcGIS Maps SDK for JavaScript 4.34
The query defining Google 3D Tiles basemaps displayed in the BasemapGallery. The fetchBasemaps() method does this automatically.
hasCategorySchema
- Type
- boolean
- Since
- ArcGIS Maps SDK for JavaScript 4.8
Indicates whether the organization has content categories.
- Default value
- false
hasClassificationSchema
- Type
- boolean
- Since
- ArcGIS Maps SDK for JavaScript 4.31
Indicates whether the organization has classification schema.
- Default value
- false
helperServices
- Since
- ArcGIS Maps SDK for JavaScript 4.4
This class contains properties to obtain information for various web services available on the portal.
This is useful for determining the URLs for relevant methods from the portal.helperServices object.
The url property of each helper service is the URL to the REST endpoint for that service.
It is recommended to use these URLs with their respective rest modules instead of the deprecated helper methods.
For additional information about helper services,
see the about utility services
topic from the ArcGIS Server documentation.
Example
// create new Portal object with relevant URLconst portal = new Portal({ url: "YOUR_PORTAL_URL"});
// load Portal instanceportal.load().then(function() { // display all helper services console.log("Show available helperServices: ", portal.helperServices); // access helperServices from the Portal instance // to get the routing URL of interest const routeURL = portal.helperServices.route.url; // use helperServices to perform routing route.solve(routeURL, routeParams).then(showRouteInfo);} isReadOnly
- Type
- boolean
- Since
- ArcGIS Maps SDK for JavaScript 4.14
Indicates if the portal is in read-only mode.
When true, content cannot be created, modified,
or deleted on the Portal.
- Default value
- false
loaded
- Type
- boolean
Indicates whether the portal's resources have loaded. When true,
all the properties of the object can be accessed.
- Default value
- false
loadError
The Error object returned if an error occurred while loading.
loadStatus
- Type
- "not-loaded" | "loading" | "failed" | "loaded"
Represents the status of a load() operation.
| Value | Description |
|---|---|
| not-loaded | The object's resources have not loaded. |
| loading | The object's resources are currently loading. |
| loaded | The object's resources have loaded without errors. |
| failed | The object's resources failed to load. See loadError for more details. |
- Default value
- "not-loaded"
loadWarnings
- Type
- any[]
A list of warnings which occurred while loading.
maxTokenExpirationMinutes
The maximum validity in minutes of tokens issued for users of the organization. -1 is the default and is a special value that indicates infinite timeout or permanent tokens. For tokens granted using OAuth 2.0 authorization grant, it represents the maximum validity of refresh tokens. For access tokens, the maximum validity is the lower of two weeks or this value.
portalProperties
- Type
- any
Properties specific to the organization, for example the "contact us" link. If the organization is public, the properties are visible to the anonymous user.
recycleBinEnabled
- Type
- boolean
- Since
- ArcGIS Maps SDK for JavaScript 4.30
Indicates whether the recycle bin is enabled for the organization.
- Default value
- false
restUrl
- Type
- string
The REST URL for the portal, for example "https://www.arcgis.com/sharing/rest" for ArcGIS Online and "https://www.example.com/arcgis/sharing/rest" for your in-house portal.
showHomePageDescription
- Type
- boolean
Indicates whether the description of your organization displays on the home page.
- Default value
- false
sourceJSON
- Type
- any
- Since
- ArcGIS Maps SDK for JavaScript 4.13
The JSON used to create the property values when the Portal is loaded.
Although most commonly used properties are exposed on the Portal class directly,
this provides access to all information returned by the portal. This property is
useful if working in an application built using an older version of the API which
requires access to portal properties from a more recent version.
- See also
supportsHostedServices
- Type
- boolean
Indicates whether hosted services are supported.
- Default value
- false
url
- Type
- string
The URL to the portal instance. Setting the location of the portal instance via esriConfig.portalUrl should be used in favor of setting it directly on this property.
If using an on-premise portal, the syntax should look similar to:
https://www.example.com/arcgis
Default Value: The default value for this property is the same as the esriConfig.portalUrl property value.
use3dBasemaps
- Type
- boolean
- Since
- ArcGIS Maps SDK for JavaScript 4.27
When false, 3D basemaps are hidden from the BasemapGallery, regardless
of the type of the view.
- Default value
- true
useDefault3dBasemap
- Type
- boolean
- Since
- ArcGIS Maps SDK for JavaScript 4.31
When false, The default 3d basemap is not used in the SceneViewer.
- Default value
- false
user
- Type
- PortalUser | null | undefined
Information representing a registered user of the portal.
useStandardizedQuery
- Type
- boolean
When true, only simple where clauses that are compliant with SQL92 can be used when querying layers and tables.
The recommended security setting is true.
- Default value
- false
useVectorBasemaps
- Type
- boolean
- Since
- ArcGIS Maps SDK for JavaScript 4.4
When true, the organization has opted in to use the vector tile basemaps,
and (a) vectorBasemapGalleryGroupQuery should
be used instead of basemapGalleryGroupQuery, while
(b) defaultVectorBasemap should be used instead of defaultBasemap.
The fetchBasemaps() method automatically uses vectorBasemapGalleryGroupQuery.
- Default value
- false
vectorBasemapGalleryGroupQuery
- Since
- ArcGIS Maps SDK for JavaScript 4.4
The query that defines the vector tiles basemaps that should be displayed in the BasemapGallery when useVectorBasemaps is true. The fetchBasemaps() method does this automatically.
Methods
| Method | Signature | Class |
|---|---|---|
fromJSON inherited static | fromJSON(json: any): any | |
getDefault static | getDefault(): Portal | |
cancelLoad inherited | cancelLoad(): this | |
createElevationLayers(): Promise<ElevationLayer[]> | | |
fetchBasemaps(basemapGalleryGroupQuery?: string, options?: FetchBasemapsOptions | null | undefined): Promise<Basemap[]> | | |
fetchCategorySchema(options?: AbortOptions | null | undefined): Promise<object[]> | | |
fetchClassificationSchema(options?: AbortOptions | null | undefined): Promise<object | null | undefined> | | |
fetchDefault3DBasemap(options?: AbortOptions): Promise<Basemap | null | undefined> | | |
fetchFeaturedGroups(options?: AbortOptions | null | undefined): Promise<PortalGroup[]> | | |
fetchRegions(options?: AbortOptions | null | undefined): Promise<object[]> | | |
fetchSettings(options?: AbortOptions | null | undefined): Promise<object> | | |
isFulfilled inherited | isFulfilled(): boolean | |
isRejected inherited | isRejected(): boolean | |
isResolved inherited | isResolved(): boolean | |
load inherited | load(options?: AbortOptions | null | undefined): Promise<this> | |
queryGroups(queryParams: PortalQueryParamsProperties, options?: AbortOptions | null | undefined): Promise<PortalQueryResult<PortalGroup>> | | |
queryItems(queryParams: PortalQueryParamsProperties, options?: AbortOptions | null | undefined): Promise<PortalQueryResult<PortalItem>> | | |
queryUsers(queryParams: PortalQueryParamsProperties, options?: AbortOptions | null | undefined): Promise<PortalQueryResult<PortalUser>> | | |
toJSON inherited | toJSON(): any | |
when inherited | when<TResult1 = this, TResult2 = never>(onFulfilled?: OnFulfilledCallback<this, TResult1> | null | undefined, onRejected?: OnRejectedCallback<TResult2> | null | undefined): Promise<TResult1 | TResult2> |
fromJSON
- Signature
-
fromJSON (json: any): any
Creates a new instance of this class and initializes it with values from a JSON object
generated from an ArcGIS product. The object passed into the input json
parameter often comes from a response to a query operation in the REST API or a
toJSON()
method from another ArcGIS product. See the Using fromJSON()
topic in the Guide for details and examples of when and how to use this function.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| json | A JSON representation of the instance in the ArcGIS format. See the ArcGIS REST API documentation for examples of the structure of various input JSON objects. | |
- Returns
- any
Returns a new instance of this class.
getDefault
- Signature
-
getDefault (): Portal
A new Portal instance is created the first time this method is called. The URL from
Config is automatically used for this instance.
This instance is then cached and used for any subsequent calls to this method.
- Returns
- Portal
The Portal instance.
cancelLoad
- Signature
-
cancelLoad (): this
Cancels a load() operation if it is already in progress.
- Returns
- this
createElevationLayers
- Signature
-
createElevationLayers (): Promise<ElevationLayer[]>
- Since
- ArcGIS Maps SDK for JavaScript 4.12
A helper function that returns an array of ElevationsLayers derived from the Portal's Limited Error Raster Compression (LERC) elevation helper service.
- See also
- Returns
- Promise<ElevationLayer[]>
When resolved, returns an array of ElevationLayers.
fetchBasemaps
- Signature
-
fetchBasemaps (basemapGalleryGroupQuery?: string, options?: FetchBasemapsOptions | null | undefined): Promise<Basemap[]>
Fetches the basemaps that are displayed in the
BasemapGallery. When an Config is defined, the basemaps will be based on
devBasemapGalleryGroupQuery.
When useVectorBasemaps is true, the basemaps will be based on
vectorBasemapGalleryGroupQuery. Otherwise, it is based on
basemapGalleryGroupQuery.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| basemapGalleryGroupQuery | When provided, this argument is used to fetch basemaps based on input query parameters. | | |
| options | An object with the following properties. | |
Example
portal.fetchBasemaps("title:\"Cloud Creek Basemaps\" AND owner:jsmith") .then(function(basemaps){ // do something with the basemaps }); fetchCategorySchema
- Signature
-
fetchCategorySchema (options?: AbortOptions | null | undefined): Promise<object[]>
- Since
- ArcGIS Maps SDK for JavaScript 4.8
If present, fetches the organization's category schema.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| options | An object with the following properties. | |
Example
// Fetches the category schemaportal.fetchCategorySchema().then(function(schemas){ schemas.forEach(function(schema){ console.log("schema: ", schema); });}); fetchClassificationSchema
- Signature
-
fetchClassificationSchema (options?: AbortOptions | null | undefined): Promise<object | null | undefined>
- Since
- ArcGIS Maps SDK for JavaScript 4.32
If present, fetches the organization's classification schema.
- See also
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| options | An object. | |
Example
// Fetches the classification schemaportal.fetchClassificationSchema().then(function(schema){ console.log("schema: ", schema);}); fetchFeaturedGroups
- Signature
-
fetchFeaturedGroups (options?: AbortOptions | null | undefined): Promise<PortalGroup[]>
Fetches the featured groups in the Portal.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| options | An object with the following properties. | |
- Returns
- Promise<PortalGroup[]>
Resolves to an array of PortalGroup objects.
Example
// fetch featured groupsportal.fetchFeaturedGroups().then(function(groups){ groups.forEach(function(group){ group.fetchMembers().then(function(members){ console.log("member", members); }); });}); fetchRegions
- Signature
-
fetchRegions (options?: AbortOptions | null | undefined): Promise<object[]>
- Since
- ArcGIS Maps SDK for JavaScript 4.8
Fetches and returns the associated regions with the portal instance.
- See also
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| options | An object with the following properties. | |
fetchSettings
- Signature
-
fetchSettings (options?: AbortOptions | null | undefined): Promise<object>
- Since
- ArcGIS Maps SDK for JavaScript 4.23
Fetches and returns the portal settings as seen by the current user(s), whether anonymous or signed in. This returns information such as any accessible helper services, allowed redirect URIs, and the configuration for any access notices or information banners.
- See also
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| options | An object with the following properties. | |
isFulfilled
- Signature
-
isFulfilled (): boolean
isFulfilled() may be used to verify if creating an instance of the class is fulfilled (either resolved or rejected).
If it is fulfilled, true will be returned.
- Returns
- boolean
Indicates whether creating an instance of the class has been fulfilled (either resolved or rejected).
isRejected
- Signature
-
isRejected (): boolean
isRejected() may be used to verify if creating an instance of the class is rejected.
If it is rejected, true will be returned.
- Returns
- boolean
Indicates whether creating an instance of the class has been rejected.
isResolved
- Signature
-
isResolved (): boolean
isResolved() may be used to verify if creating an instance of the class is resolved.
If it is resolved, true will be returned.
- Returns
- boolean
Indicates whether creating an instance of the class has been resolved.
load
- Signature
-
load (options?: AbortOptions | null | undefined): Promise<this>
Loads the resources referenced by this class. This method automatically executes for a View and all of the resources it references in Map if the view is constructed with a map instance.
This method must be called by the developer when accessing a resource that will not be loaded in a View.
The load() method only triggers the loading of the resource the first time it is called. The subsequent calls return the same promise.
It's possible to provide a signal to stop being interested into a Loadable instance load status.
When the signal is aborted, the instance does not stop its loading process, only cancelLoad() can abort it.
queryGroups
- Signature
-
queryGroups (queryParams: PortalQueryParamsProperties, options?: AbortOptions | null | undefined): Promise<PortalQueryResult<PortalGroup>>
Executes a query against the Portal to return an array of PortalGroup objects that match the input query.
- See also
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| queryParams | The input query parameters defined in PortalQueryParams. | | |
| options | An object with the following properties. | |
- Returns
- Promise<PortalQueryResult<PortalGroup>>
When resolved, resolves to an instance of PortalQueryResult which contains a
resultsarray of PortalGroup objects representing all the groups that match the input query.
queryItems
- Signature
-
queryItems (queryParams: PortalQueryParamsProperties, options?: AbortOptions | null | undefined): Promise<PortalQueryResult<PortalItem>>
Executes a query against the Portal to return an array of PortalItem objects that match the input query.
- See also
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| queryParams | The input query parameters defined in PortalQueryParams. | | |
| options | An object with the following properties. | |
- Returns
- Promise<PortalQueryResult<PortalItem>>
When resolved, resolves to an instance of PortalQueryResult which contains a
resultsarray of PortalItem objects representing all the items that match the input query.
Example
// Once portal is loaded, user signed in portal.load().then(function() { console.log(portal);
// Create query parameters for the portal search // This object autocasts as new PortalQueryParams() let queryParams = { query: "owner:" + portal.user.username, sortField: "numViews", sortOrder: "desc", num: 20 };
// Query the items based on the queryParams created from portal above portal.queryItems(queryParams).then(createGallery); }); queryUsers
- Signature
-
queryUsers (queryParams: PortalQueryParamsProperties, options?: AbortOptions | null | undefined): Promise<PortalQueryResult<PortalUser>>
Executes a query against the Portal to return an array of PortalUser objects that match the input query.
- See also
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| queryParams | The input query parameters defined in PortalQueryParams. | | |
| options | An object with the following properties. | |
- Returns
- Promise<PortalQueryResult<PortalUser>>
When resolved, resolves to an instance of PortalQueryResult which contains a
resultsarray of PortalUser objects representing all the items that match the input query.
Example
// Once portal is loaded, user signed inportal.load().then(function() { // queryUsers // This object autocasts as new PortalQueryParams() let queryParameters = { query: "username:" + portal.user.username };
portal.queryUsers(queryParameters).then(function(queryResults){ queryResults.results[0].fetchFolders().then(function(folders){ folders.forEach(function(folder){ console.log(" user folder", folder.title); }); }); });}); toJSON
- Signature
-
toJSON (): any
Converts an instance of this class to its ArcGIS portal JSON representation. See the Using fromJSON() guide topic for more information.
- Returns
- any
The ArcGIS portal JSON representation of an instance of this class.
when
- Signature
-
when <TResult1 = this, TResult2 = never>(onFulfilled?: OnFulfilledCallback<this, TResult1> | null | undefined, onRejected?: OnRejectedCallback<TResult2> | null | undefined): Promise<TResult1 | TResult2>
- Since
- ArcGIS Maps SDK for JavaScript 4.6
when() may be leveraged once an instance of the class is created. This method takes two input parameters: an onFulfilled function and an onRejected function.
The onFulfilled executes when the instance of the class loads. The
onRejected executes if the instance of the class fails to load.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| onFulfilled | OnFulfilledCallback<this, TResult1> | null | undefined | The function to call when the promise resolves. | |
| onRejected | The function to execute when the promise fails. | |
- Returns
- Promise<TResult1 | TResult2>
Returns a new promise for the result of
onFulfilledthat may be used to chain additional functions.
Example
// Although this example uses MapView, any class instance that is a promise may use when() in the same waylet view = new MapView();view.when(function(){ // This function will execute once the promise is resolved}, function(error){ // This function will execute if the promise is rejected due to an error});