Click or drag to resize

PortalItemCreateAsync Method (ArcGISPortal, String)

Initializes a new instance of the PortalItem class from the specified item ID.

Namespace:  Esri.ArcGISRuntime.Portal
Assembly:  Esri.ArcGISRuntime (in Esri.ArcGISRuntime.dll) Version: 100.11.0
public static Task<PortalItem> CreateAsync(
	ArcGISPortal portal,
	string itemId


Type: Esri.ArcGISRuntime.PortalArcGISPortal
The ArcGIS portal.
Type: SystemString
The item Id.

Return Value

Type: TaskPortalItem
The task object representing the asynchronous create operation. The value of the task result is a PortalItem object.
The portal itemId can be determined from the URL of the item details web page or the map viewer URL (for maps only) in your portal. The item details page has the following format ([item_id]). The webmap viewer has the following format ([item_id]). In both cases, the [item_id] can be used as the ID to instantiate a portal item.


Example Name: MapReferenceScale

Set the map's reference scale and which feature layers should honor the reference scale.

Code example screen shot.

// Copyright 2019 Esri.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at:
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
// language governing permissions and limitations under the License.

using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.Portal;
using System;

namespace ArcGISRuntime.WPF.Samples.MapReferenceScale
        name: "Map reference scale",
        category: "Map",
        description: "Set the map's reference scale and which feature layers should honor the reference scale.",
        instructions: "Use the control at the top to set the map's reference scale (1:500,000 1:250,000 1:100,000 1:50,000). Use the menu checkboxes in the layer menu to set which feature layers should honor the reference scale.",
        tags: new[] { "map", "reference scale", "scene" })]
    public partial class MapReferenceScale
        // List of reference scale options.
        private readonly double[] _referenceScales =

        public MapReferenceScale()

        private async void Initialize()
            // Populate the reference scale choices.
            ReferenceScaleBox.ItemsSource = _referenceScales;

            // Create a portal and an item; the map will be loaded from portal item.
            ArcGISPortal portal = await ArcGISPortal.CreateAsync(new Uri(""));
            PortalItem mapItem = await PortalItem.CreateAsync(portal, "3953413f3bd34e53a42bf70f2937a408");

            // Create the map from the item.
            Map webMap = new Map(mapItem);

            // Display the map.
            MyMapView.Map = webMap;

            // NOTE: this sample uses binding, so explicit control of reference scale isn't seen here.
            // See the iOS or Android samples for an implementation that does not rely on data binding.
        <esri:MapView x:Name="MyMapView" />
        <Border Style="{StaticResource BorderStyle}">
                <TextBlock FontWeight="SemiBold" Text="Choose a map reference scale:" />
                <!--  When the user's selection changes, the SelectedItem binding will apply the value to the Map's ReferenceScale property.  -->
                    SelectedItem="{Binding ElementName=MyMapView, Path=Map.ReferenceScale}">
                                <!--  Runs are used to format a plain double to match the convention for writing map scales.  -->
                                <Run Text="1:" />
                                <Run Text="{Binding Path=., StringFormat=n0}" />
                <TextBlock FontWeight="SemiBold" Text="Choose layers to apply scale to:" />
                <!--  Binding is used to display the operational layers for the map view's map, no code behind needed.  -->
                <ListView Margin="0,5,0,5" ItemsSource="{Binding ElementName=MyMapView, Path=Map.OperationalLayers}">
                        <DataTemplate DataType="esri:FeatureLayer">
                                When the user interacts with the checkbox,
                                the two-way binding will update the ScaleSymbols (bool) property automatically.
                            <CheckBox Content="{Binding Name}" IsChecked="{Binding ScaleSymbols}" />
                    <!--  A run is used to format the label.  -->
                    <Run Text="Current map scale: " />
                    <Run Text="1:" />
                    <Run Text="{Binding ElementName=MyMapView, Path=MapScale, Mode=OneWay, StringFormat=n0}" />
See Also
Additional Examples
Hyperlink to ExampleDescription
DisplayKmlDisplay KML from a URL, portal item, or local KML file.
DownloadPreplannedMapTake a map offline using a preplanned map area.
FeatureCollectionLayerFromPortalCreate a feature collection layer from a portal item.
GenerateOfflineMapTake a web map offline.
GenerateOfflineMapWithOverridesTake a web map offline with additional options for each layer.
IntegratedWindowsAuthConnect to an IWA secured Portal and search for maps.
MapReferenceScaleSet the map's reference scale and which feature layers should honor the reference scale.
OAuthAuthenticate with ArcGIS Online (or your own portal) using OAuth2 to access secured resources (such as private web maps or layers).
OfflineBasemapByReferenceUse the `OfflineMapTask` to take a web map offline, but instead of downloading an online basemap, use one which is already on the device.
OpenScenePortalItemOpen a web scene from a portal item.
ViewContentBeneathSurfaceSee through terrain in a scene and move the camera underground.