private async void UpdatePortalItemThumbnailAsync(string thumbnailImagePath) { // Update the portal item with the thumbnail image passed in try { // Get the map's portal item PortalItem newPortalItem = MyMapView.Map.Item as PortalItem; // Open the image file var thumbnailData = new FileStream(thumbnailImagePath, FileMode.Open); // Assign the thumbnail data (file stream) to the content object newPortalItem.SetThumbnailWithImage(thumbnailData); // Update the portal item with the new content (just the thumbnail will be updated) await newPortalItem.UpdateItemPropertiesAsync(); // Close the stream and delete the local jpg file from disk thumbnailData.Close(); File.Delete(thumbnailImagePath); } catch (Exception ex) { MessageBox.Show("Unable to update thumbnail for portal item: " + ex.Message, "Portal Item Thumbnail"); } }
private async void UpdatePortalItemThumbnailAsync(string imageFileName) { // Update the portal item with a thumbnail image of the current map try { // Get the map's portal item PortalItem newPortalItem = MyMapView.Map.Item as PortalItem; // Open the image file (stored in the device's Pictures folder) var mapImageFile = await KnownFolders.PicturesLibrary.GetFileAsync(imageFileName); if (mapImageFile != null) { // Get a thumbnail image (scaled down version) of the original var thumbnailData = await mapImageFile.GetScaledImageAsThumbnailAsync(0); // Assign the thumbnail data (file stream) to the content object newPortalItem.SetThumbnailWithImage(thumbnailData.AsStreamForRead()); // Update the portal item with the new content (just the thumbnail will be updated) await newPortalItem.UpdateItemPropertiesAsync(); // Delete the map image file from disk mapImageFile.DeleteAsync(); } } catch (Exception ex) { // Warn the user that the thumbnail could not be updated var dialog = new MessageDialog("Unable to update thumbnail for portal item: " + ex.Message, "Portal Item Thumbnail"); dialog.ShowAsync(); } }