private async void OpenFeaturesFromArcGISOnline(string itemId)
{
try
{
// Open a portal item containing a feature collection
ArcGISPortal portal = await ArcGISPortal.CreateAsync();
PortalItem collectionItem = await PortalItem.CreateAsync(portal, itemId);
// Verify that the item is a feature collection
if (collectionItem.Type == PortalItemType.FeatureCollection)
{
// Create a new FeatureCollection from the item
FeatureCollection featureCollection = new FeatureCollection(collectionItem);
// Create a layer to display the collection and add it to the map as an operational layer
FeatureCollectionLayer featureCollectionLayer = new FeatureCollectionLayer(featureCollection);
featureCollectionLayer.Name = collectionItem.Title;
MyMapView.Map.OperationalLayers.Add(featureCollectionLayer);
}
else
{
var messageDlg = new MessageDialog("Portal item with ID '" + itemId + "' is not a feature collection.", "Feature Collection");
messageDlg.ShowAsync();
}
}catch(Exception ex)
{
var messageDlg = new MessageDialog("Unable to open item with ID '" + itemId + "': " + ex.Message, "Error");
messageDlg.ShowAsync();
}
}