protected override async void OnElementChanged(ElementChangedEventArgs<Page> e)
{
// Call the method on the base
base.OnElementChanged(e);
// Exit if the element (Page) is null
if (e.OldElement != null || Element == null)
{
return;
}
// Set up the AuthenticationManager to challenge for ArcGIS Online credentials
UpdateAuthenticationManager();
// Force an OAuth challenge
CredentialRequestInfo info = new CredentialRequestInfo
{
AuthenticationType = AuthenticationType.Token,
ServiceUri = new Uri(OAuthPage.PortalUrl)
};
await AuthenticationManager.Current.GetCredentialAsync(info, false);
// Open the desired web map (portal item)
ArcGISPortal portal = await ArcGISPortal.CreateAsync(new Uri(OAuthPage.PortalUrl));
PortalItem item = await PortalItem.CreateAsync(portal, OAuthPage.WebMapId);
// Create a map
Map myMap = new Map(item);
// Set the MyMap property on the shared form to display the map in the map view
var oauthPage = e.NewElement as OAuthPage;
oauthPage.MyMap = myMap;
}