private async void OnSaveMapClick(object sender, RoutedEventArgs e) { try { // Create a challenge request for portal credentials (OAuth credential request for arcgis.com) CredentialRequestInfo challengeRequest = new CredentialRequestInfo(); // Use the OAuth implicit grant flow challengeRequest.GenerateTokenOptions = new GenerateTokenOptions { TokenAuthenticationType = TokenAuthenticationType.OAuthImplicit }; // Indicate the url (portal) to authenticate with (ArcGIS Online) challengeRequest.ServiceUri = new Uri("https://www.arcgis.com/sharing/rest"); // Call GetCredentialAsync on the AuthenticationManager to invoke the challenge handler await AuthenticationManager.Current.GetCredentialAsync(challengeRequest, false); // Get information for the new portal item var title = TitleTextBox.Text; var description = DescriptionTextBox.Text; var tags = TagsTextBox.Text.Split(','); // Throw an exception if the text is null or empty for title or description if (string.IsNullOrEmpty(title) || string.IsNullOrEmpty(description)) { throw new Exception("Title and description are required"); } // Get current map extent (viewpoint) for the map initial extent var currentViewpoint = MyMapView.GetCurrentViewpoint(Esri.ArcGISRuntime.Mapping.ViewpointType.BoundingGeometry); // Export the current map view to use as the item's thumbnail RuntimeImage thumbnailImg = await MyMapView.ExportImageAsync(); // See if the map has already been saved if (!_mapViewModel.MapIsSaved) { // Call the SaveNewMapAsync method on the view model, pass in the required info await _mapViewModel.SaveNewMapAsync(currentViewpoint, title, description, tags, thumbnailImg); // Report success MessageBox.Show("Map '" + title + "' was saved to your portal"); } else { // Map has previously been saved as a portal item, update it (title, description, and tags will remain the same) _mapViewModel.UpdateMapItem(); // Report success MessageBox.Show("Changes to '" + title + "' were updated to the portal."); } } catch (Exception ex) { // Report error MessageBox.Show("Error while saving: " + ex.Message); } }
private async void OnTakeScreenshotClicked(object sender, EventArgs e) { // Make sure an image is not in progress (check the activity indicator) if (CreatingImageIndicator.IsVisible) { return; } // Show the activity indicator while the image is being created CreatingImageIndicator.IsVisible = true; try { // Export the image from mapview and assign it to the imageview RuntimeImage exportedImage = await MyMapView.ExportImageAsync(); // Create layout for sublayers page // Create root layout StackLayout layout = new StackLayout(); Button closeButton = new Button { Text = "Close" }; closeButton.Clicked += CloseButton_Clicked; // Create image bitmap by getting stream from the exported image var buffer = await exportedImage.GetEncodedBufferAsync(); byte[] data = new byte[buffer.Length]; buffer.Read(data, 0, data.Length); var bitmap = ImageSource.FromStream(() => new MemoryStream(data)); Image image = new Image() { Source = bitmap, Margin = new Thickness(10) }; // Add elements into the layout layout.Children.Add(closeButton); layout.Children.Add(image); // Create internal page for the navigation page ContentPage screenshotPage = new ContentPage() { Content = layout, Title = "Screenshot" }; // Hide the activity indicator CreatingImageIndicator.IsVisible = false; // Navigate to the sublayers page await Navigation.PushAsync(screenshotPage); } catch (Exception ex) { await((Page)Parent).DisplayAlert("Error", ex.ToString(), "OK"); } }
private async void OnScreenshotButtonClicked(object sender, RoutedEventArgs e) { // Export the image from mapview and display it. ImageView.Source = await(await MyMapView.ExportImageAsync()).ToImageSourceAsync(); // Make the image visible. ImageView.Visibility = Visibility.Visible; }
private async void OnTakeScreenshotClicked(object sender, EventArgs e) { try { ScreenshotButton.IsEnabled = false; // Wait for rendering to finish before taking the screenshot. await WaitForRenderCompleteAsync(MyMapView); // Export the image from the map view. RuntimeImage exportedImage = await MyMapView.ExportImageAsync(); // Create layout for sublayers page // Create root layout StackLayout layout = new StackLayout(); Button closeButton = new Button { Text = "Close" }; closeButton.Clicked += CloseButton_Clicked; // Create image bitmap by getting stream from the exported image. // NOTE: currently broken on UWP due to Xamarin.Forms bug https://github.com/xamarin/Xamarin.Forms/issues/5188. var buffer = await exportedImage.GetEncodedBufferAsync(); byte[] data = new byte[buffer.Length]; buffer.Read(data, 0, data.Length); var bitmap = ImageSource.FromStream(() => new MemoryStream(data)); Image image = new Image() { Source = bitmap, Margin = new Thickness(10) }; // Add elements into the layout. layout.Children.Add(closeButton); layout.Children.Add(image); // Create internal page for the navigation page. ContentPage screenshotPage = new ContentPage() { Content = layout, Title = "Screenshot" }; // Navigate to the sublayers page. await Navigation.PushAsync(screenshotPage); } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("Error", ex.ToString(), "OK"); } finally { ScreenshotButton.IsEnabled = true; } }
private async void OnTakeScreenshotButtonClicked(object sender, RoutedEventArgs e) { // Export the image from mapview and assign it to the imageview. ImageSource exportedImage = await(await MyMapView.ExportImageAsync()).ToImageSourceAsync(); // Set the screenshot view to the new exported image. ScreenshotView.Source = exportedImage; // Make the screenshot view visible in the UI. ScreenshotView.Visibility = Visibility.Visible; }
private async Task <GenerateOfflineMapParameters> GenerateGeodatabaseParameters(OfflineMapTask task, PortalItem webmapItem) { // Create default parameters //Envelope areaOfInterest = new Envelope(-12211308.778729, 4645116.003309, -12208257.879667, 4650542.535773, SpatialReferences.WebMercator); //GenerateOfflineMapParameters parameters = await task.CreateDefaultGenerateOfflineMapParametersAsync(areaOfInterest); GenerateOfflineMapParameters parameters = await task.CreateDefaultGenerateOfflineMapParametersAsync(MyMapView.Map.InitialViewpoint.TargetGeometry.Extent); // Update the parameters if needed // Limit maximum scale to 5000 but take all the scales above (use 0 as a MinScale) //parameters.MaxScale = 5000; // Set attachment options parameters.AttachmentSyncDirection = AttachmentSyncDirection.Upload; parameters.ReturnLayerAttachmentOption = ReturnLayerAttachmentOption.EditableLayers; parameters.IncludeBasemap = true; // Request the table schema only (existing features won’t be included) parameters.ReturnSchemaOnlyForEditableLayers = false; // Update the title to contain the region parameters.ItemInfo.Title = parameters.ItemInfo.Title + " (Central)"; // Override thumbnail with the new image based on the extent RuntimeImage thumbnail = await MyMapView.ExportImageAsync(); // Create new item info OfflineMapItemInfo itemInfo = new OfflineMapItemInfo(); // Create new thumbnail from the map RuntimeImage thumbnailImage = await MyMapView.ExportImageAsync(); // Set values to the itemInfo itemInfo.Thumbnail = thumbnailImage; itemInfo.Title = "Water network (Central)"; itemInfo.Snippet = webmapItem.Snippet; // Copy from the source map itemInfo.Description = webmapItem.Description; // Copy from the source map itemInfo.AccessInformation = webmapItem.AccessInformation; // Copy from the source map itemInfo.Tags.Add("Water network"); itemInfo.Tags.Add("Data validation"); // Set metadata to parameters parameters.ItemInfo = itemInfo; return(parameters); }
private async void OnScreenshotButtonClicked(object sender, RoutedEventArgs e) { try { // Export the image from mapview and display it. ImageView.Source = await(await MyMapView.ExportImageAsync()).ToImageSourceAsync(); // Make the image visible. ImageView.Visibility = Visibility.Visible; } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error"); } }
private async void OnTakeScreenshotButtonClicked(object sender, RoutedEventArgs e) { try { // Export the image from mapview and assign it to the imageview. ImageSource exportedImage = await(await MyMapView.ExportImageAsync()).ToImageSourceAsync(); // Set the screenshot view to the new exported image. ScreenshotView.Source = exportedImage; // Make the screenshot view visible in the UI. ScreenshotView.Visibility = Visibility.Visible; } catch (Exception ex) { await new MessageDialog(ex.ToString(), "Error").ShowAsync(); } }
private async void OnTakeScreenshotClicked(object sender, EventArgs e) { // Export the image from mapview and assign it to the imageview var exportedImage = await MyMapView.ExportImageAsync(); // Create layout for sublayers page // Create root layout var layout = new StackLayout(); var closeButton = new Button { Text = "Close" }; closeButton.Clicked += CloseButton_Clicked; // Create image bitmap by getting stream from the exported image var buffer = await exportedImage.GetEncodedBufferAsync(); byte[] data = new byte[buffer.Length]; buffer.Read(data, 0, data.Length); var bitmap = ImageSource.FromStream(() => new System.IO.MemoryStream(data)); var image = new Image() { Source = bitmap, Margin = new Thickness(10) }; // Add elements into the layout layout.Children.Add(closeButton); layout.Children.Add(image); // Create internal page for the navigation page var screenshotPage = new ContentPage() { Content = layout, Title = "Screenshot" }; // Navigate to the sublayers page await Navigation.PushAsync(screenshotPage); }
private async void OnScreenshotButtonClicked(object sender, RoutedEventArgs e) { try { // Wait for rendering to finish before taking the screenshot. await WaitForRenderCompleteAsync(MyMapView); // Export the image from MapView. RuntimeImage image = await MyMapView.ExportImageAsync(); // Display the image in the UI. ImageView.Source = await image.ToImageSourceAsync(); // Make the image visible. ImageView.Visibility = Visibility.Visible; } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error"); } }
// Event handler to get information entered by the user and save the map private async void SaveMapAsync(object sender, ArcGISRuntime.Samples.AuthorEditSaveMap.SaveMapEventArgs e) { try { // Get information entered by the user for the new portal item properties var title = e.MapTitle; var description = e.MapDescription; var tags = e.Tags; // Get the current extent displayed in the map view var currentViewpoint = MyMapView.GetCurrentViewpoint(Esri.ArcGISRuntime.Mapping.ViewpointType.BoundingGeometry); // Export the current map view for the item's thumbnail RuntimeImage thumbnailImg = await MyMapView.ExportImageAsync(); // See if the map has already been saved if (!_mapViewModel.MapIsSaved) { // Save the map as a portal item await _mapViewModel.SaveNewMapAsync(currentViewpoint, title, description, tags, thumbnailImg); // Report a successful save DisplayAlert("Map Saved", "Saved '" + title + "' to ArcGIS Online!", "OK"); } else { // Map has previously been saved as a portal item, update it (title, description, and tags will remain the same) _mapViewModel.UpdateMapItem(); // Report success DisplayAlert("Map Updated", "Saved changes to '" + title + "'", "OK"); } } catch (Exception ex) { // Show the exception message DisplayAlert("Unable to save map", ex.Message, "OK"); } }
private async void OnTakeScreenshotClicked(object sender, EventArgs e) { // Export the image from mapview and assign it to the imageview var exportedImage = await MyMapView.ExportImageAsync(); // Create layout for sublayers page // Create root layout var layout = new StackLayout(); var closeButton = new Button { Text = "Close" }; closeButton.Clicked += CloseButton_Clicked; // Create image using exported image source var image = new Image() { Source = exportedImage, Margin = new Thickness(10) }; // Add elements into the layout layout.Children.Add(closeButton); layout.Children.Add(image); // Create internal page for the navigation page var screenshotPage = new ContentPage() { Content = layout, Title = "Screenshot" }; // Navigate to the sublayers page await Navigation.PushAsync(screenshotPage); }
private async void OnTakeScreenshotButtonClicked(object sender, RoutedEventArgs e) { try { // Wait for rendering to finish before taking the screenshot. await WaitForRenderCompleteAsync(MyMapView); // Export the image from the map view. RuntimeImage image = await MyMapView.ExportImageAsync(); // Convert the image to a displayable format. ImageSource exportedImage = await image.ToImageSourceAsync(); // Set the screenshot view to the new exported image. ScreenshotView.Source = exportedImage; // Make the screenshot view visible in the UI. ScreenshotView.Visibility = Visibility.Visible; } catch (Exception ex) { await new MessageDialog2(ex.ToString(), "Error").ShowAsync(); } }
// Event handler to get information entered by the user and save the map private async void SaveMapAsync(object sender, SaveMapEventArgs e) { // Get the current map Map myMap = MyMapView.Map; try { // Show the progress bar so the user knows work is happening SaveMapProgressBar.IsVisible = true; // Make sure the user is logged in to ArcGIS Online Credential cred = await EnsureLoggedInAsync(); AuthenticationManager.Current.AddCredential(cred); // Get information entered by the user for the new portal item properties string title = e.MapTitle; string description = e.MapDescription; string[] tags = e.Tags; // Apply the current extent as the map's initial extent myMap.InitialViewpoint = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry); // Export the current map view for the item's thumbnail RuntimeImage thumbnailImage = await MyMapView.ExportImageAsync(); // See if the map has already been saved (has an associated portal item) if (myMap.Item == null) { // Get the ArcGIS Online portal (will use credential from login above) ArcGISPortal agsOnline = await ArcGISPortal.CreateAsync(new Uri(ArcGISOnlineUrl)); // Save the current state of the map as a portal item in the user's default folder await myMap.SaveAsAsync(agsOnline, null, title, description, tags, thumbnailImage); // Report a successful save await((Page)Parent).DisplayAlert("Map Saved", "Saved '" + title + "' to ArcGIS Online!", "OK"); } else { // This is not the initial save, call SaveAsync to save changes to the existing portal item await myMap.SaveAsync(); // Get the file stream from the new thumbnail image Stream imageStream = await thumbnailImage.GetEncodedBufferAsync(); // Update the item thumbnail ((PortalItem)myMap.Item).SetThumbnailWithImage(imageStream); await myMap.SaveAsync(); // Report update was successful await((Page)Parent).DisplayAlert("Updates Saved", "Saved changes to '" + myMap.Item.Title + "'", "OK"); } } catch (Exception ex) { // Show the exception message await((Page)Parent).DisplayAlert("Unable to save map", ex.Message, "OK"); } finally { // Hide the progress bar SaveMapProgressBar.IsVisible = false; } }
private async void SaveMapClicked(object sender, RoutedEventArgs e) { try { // Show the progress bar so the user knows work is happening SaveProgressBar.Visibility = Visibility.Visible; // Get the current map Map myMap = MyMapView.Map; // Apply the current extent as the map's initial extent myMap.InitialViewpoint = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry); // Get the current map view for the item thumbnail RuntimeImage thumbnailImg = await MyMapView.ExportImageAsync(); // See if the map has already been saved (has an associated portal item) if (myMap.Item == null) { // Get information for the new portal item string title = TitleTextBox.Text; string description = DescriptionTextBox.Text; string[] tags = TagsTextBox.Text.Split(','); // Make sure all required info was entered if (String.IsNullOrEmpty(title) || String.IsNullOrEmpty(description) || tags.Length == 0) { throw new Exception("Please enter a title, description, and some tags to describe the map."); } // Call a function to save the map as a new portal item await SaveNewMapAsync(MyMapView.Map, title, description, tags, thumbnailImg); // Report a successful save MessageBox.Show("Saved '" + title + "' to ArcGIS Online!", "Map Saved"); } else { // This is not the initial save, call SaveAsync to save changes to the existing portal item await myMap.SaveAsync(); // Get the file stream from the new thumbnail image Stream imageStream = await thumbnailImg.GetEncodedBufferAsync(); // Update the item thumbnail ((PortalItem)myMap.Item).SetThumbnail(imageStream); await myMap.SaveAsync(); // Report update was successful MessageBox.Show("Saved changes to '" + myMap.Item.Title + "'", "Updates Saved"); } } catch (Exception ex) { // Report error message MessageBox.Show("Error saving map to ArcGIS Online: " + ex.Message); } finally { // Hide the progress bar SaveProgressBar.Visibility = Visibility.Hidden; } }
private async void OnScreenshotButtonClicked(object sender, RoutedEventArgs e) { // Export the image from mapview and assign it to the imageview imageView.Source = await Esri.ArcGISRuntime.UI.RuntimeImageExtensions.ToImageSourceAsync(await MyMapView.ExportImageAsync()); }
private async void GenerateOnDemand() { ArcGISPortal portal = await ArcGISPortal.CreateAsync(); // Get a web map item using its ID. PortalItem webmapItem = await PortalItem.CreateAsync(portal, "dba73588a56d476484b8d0fa1c480c9b"); // Create a map from the web map item. Map onlineMap = new Map(webmapItem); // Create an OfflineMapTask from the map ... OfflineMapTask takeMapOfflineTask = await OfflineMapTask.CreateAsync(onlineMap); // ... or a web map portal item. takeMapOfflineTask = await OfflineMapTask.CreateAsync(webmapItem); await onlineMap.LoadAsync(); // Create default parameters for the task. Envelope areaOfInterest = GetAreaOfInterest(); GenerateOfflineMapParameters parameters = await takeMapOfflineTask.CreateDefaultGenerateOfflineMapParametersAsync(areaOfInterest); // Limit the maximum scale to 5000 but take all the scales above (use default of 0 as the MinScale). parameters.MaxScale = 5000; // Set attachment options. parameters.AttachmentSyncDirection = AttachmentSyncDirection.Upload; parameters.ReturnLayerAttachmentOption = ReturnLayerAttachmentOption.EditableLayers; // Request the table schema only (existing features won’t be included). parameters.ReturnSchemaOnlyForEditableLayers = true; // Update the map title to contain the region. parameters.ItemInfo.Title = parameters.ItemInfo.Title + " (Central)"; // Override the thumbnail with a new image based on the extent. RuntimeImage thumbnail = await MyMapView.ExportImageAsync(); parameters.ItemInfo.Thumbnail = thumbnail; // Create the job to generate an offline map, pass in the parameters and a path to store the map package. GenerateOfflineMapJob generateMapJob = takeMapOfflineTask.GenerateOfflineMap(parameters, pathToOutputPackage); // Generate the offline map and download it. GenerateOfflineMapResult offlineMapResult = await generateMapJob.GetResultAsync(); if (!offlineMapResult.HasErrors) { // Job completed successfully and all content was generated. Debug.WriteLine("Map " + offlineMapResult.MobileMapPackage.Item.Title + " was saved to " + offlineMapResult.MobileMapPackage.Path); // Show the offline map in a MapView. MyMapView.Map = offlineMapResult.OfflineMap; } else { // Job is finished but one or more layers or tables had errors. if (offlineMapResult.LayerErrors.Count > 0) { // Show layer errors. foreach (var layerError in offlineMapResult.LayerErrors) { Debug.WriteLine("Error occurred when taking " + layerError.Key.Name + " offline. Error : " + layerError.Value.Message); } } if (offlineMapResult.TableErrors.Count > 0) { // Show table errors. foreach (var tableError in offlineMapResult.TableErrors) { Debug.WriteLine("Error occurred when taking " + tableError.Key.TableName + " offline. Error : " + tableError.Value.Message); } } } OfflineMapCapabilities results = await takeMapOfflineTask.GetOfflineMapCapabilitiesAsync(parameters); if (results.HasErrors) { // Handle possible errors with layers foreach (var layerCapability in results.LayerCapabilities) { if (!layerCapability.Value.SupportsOffline) { Debug.WriteLine(layerCapability.Key.Name + " cannot be taken offline. Error : " + layerCapability.Value.Error.Message); } } // Handle possible errors with tables foreach (var tableCapability in results.TableCapabilities) { if (!tableCapability.Value.SupportsOffline) { Debug.WriteLine(tableCapability.Key.TableName + " cannot be taken offline. Error : " + tableCapability.Value.Error.Message); } } } else { // All layers and tables can be taken offline! MessageBox.Show("All layers are good to go!"); } // Create a mobile map package from an unpacked map package folder. MobileMapPackage offlineMapPackage = await MobileMapPackage.OpenAsync(pathToOutputPackage); // Set the title from the package metadata to the UI // Get the map from the package and set it to the MapView var map = offlineMapPackage.Maps.First(); MyMapView.Map = map; }
private async void SaveMapClicked(object sender, RoutedEventArgs e) { try { // Show the progress bar so the user knows work is happening SaveProgressBar.Visibility = Visibility.Visible; // Get the current map var myMap = MyMapView.Map; // Apply the current extent as the map's initial extent myMap.InitialViewpoint = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry); // See if the map has already been saved (has an associated portal item) if (myMap.Item == null) { // Get information for the new portal item var title = TitleTextBox.Text; var description = DescriptionTextBox.Text; var tags = TagsTextBox.Text.Split(','); // Make sure all required info was entered if (string.IsNullOrEmpty(title) || string.IsNullOrEmpty(description) || tags.Length == 0) { throw new Exception("Please enter a title, description, and some tags to describe the map."); } // Call a function to save the map as a new portal item await SaveNewMapAsync(MyMapView.Map, title, description, tags); // Report a successful save MessageBox.Show("Saved '" + title + "' to ArcGIS Online!", "Map Saved"); } else { // This is not the initial save, call SaveAsync to save changes to the existing portal item await myMap.SaveAsync(); // Report update was successful MessageBox.Show("Saved changes to '" + myMap.Item.Title + "'", "Updates Saved"); } // Update the portal item thumbnail with the current map image try { // Export the current map view var mapImage = await Esri.ArcGISRuntime.UI.RuntimeImageExtensions.ToImageSourceAsync(await MyMapView.ExportImageAsync()); // Call a function that writes a temporary jpeg file of the map var imagePath = await WriteTempThumbnailImageAsync(mapImage); // Call a function to update the portal item's thumbnail with the image UpdatePortalItemThumbnailAsync(imagePath); } catch { // Throw an exception to let the user know the thumbnail was not saved (the map item was) throw new Exception("Thumbnail was not updated."); } } catch (Exception ex) { // Report error message MessageBox.Show("Error saving map to ArcGIS Online: " + ex.Message); } finally { // Hide the progress bar SaveProgressBar.Visibility = Visibility.Hidden; } }
private async void OnTakeScreenshotButtonClicked(object sender, RoutedEventArgs e) { // Export the image from mapview and assign it to the imageview var exportedImage = await Esri.ArcGISRuntime.UI.RuntimeImageExtensions.ToImageSourceAsync(await MyMapView.ExportImageAsync()); // Create dialog that is used to show the picture var dialog = new ContentDialog() { Title = "Screenshot", MaxWidth = ActualWidth, MaxHeight = ActualHeight }; // Create Image var imageView = new Image() { Source = exportedImage, Margin = new Thickness(10) }; // Set image as a content dialog.Content = imageView; // Show dialog as a full screen overlay. await dialog.ShowAsync(); }
private async void SaveMapClicked(object sender, RoutedEventArgs e) { try { // Don't attempt to save if the OAuth settings weren't provided if (string.IsNullOrEmpty(AppClientId) || string.IsNullOrEmpty(OAuthRedirectUrl)) { var dialog = new MessageDialog("OAuth settings were not provided.", "Cannot Save"); await dialog.ShowAsync(); SaveMapFlyout.Hide(); return; } // Show the progress bar so the user knows work is happening SaveProgressBar.Visibility = Visibility.Visible; // Get the current map var myMap = MyMapView.Map; // Apply the current extent as the map's initial extent myMap.InitialViewpoint = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry); // Export the current map view to use as the item's thumbnail RuntimeImage thumbnailImg = await MyMapView.ExportImageAsync(); // See if the map has already been saved (has an associated portal item) if (myMap.Item == null) { // Get information for the new portal item var title = TitleTextBox.Text; var description = DescriptionTextBox.Text; var tagText = TagsTextBox.Text; // Make sure all required info was entered if (string.IsNullOrEmpty(title) || string.IsNullOrEmpty(description) || string.IsNullOrEmpty(tagText)) { throw new Exception("Please enter a title, description, and some tags to describe the map."); } // Call a function to save the map as a new portal item await SaveNewMapAsync(MyMapView.Map, title, description, tagText.Split(','), thumbnailImg); // Report a successful save var messageDialog = new MessageDialog("Saved '" + title + "' to ArcGIS Online!", "Map Saved"); await messageDialog.ShowAsync(); } else { // This is not the initial save, call SaveAsync to save changes to the existing portal item await myMap.SaveAsync(); // Get the file stream from the new thumbnail image Stream imageStream = await thumbnailImg.GetEncodedBufferAsync(); // Update the item thumbnail (myMap.Item as PortalItem).SetThumbnailWithImage(imageStream); await myMap.SaveAsync(); // Report update was successful var messageDialog = new MessageDialog("Saved changes to '" + myMap.Item.Title + "'", "Updates Saved"); await messageDialog.ShowAsync(); } } catch (Exception ex) { // Report error message var messageDialog = new MessageDialog("Error saving map to ArcGIS Online: " + ex.Message); await messageDialog.ShowAsync(); } finally { // Hide the progress bar SaveProgressBar.Visibility = Visibility.Collapsed; } }