ArcGISRuntimeXamarin.Samples.AuthorEditSaveMap.MapViewModel.SaveNewMapAsync C# (CSharp) 메소드

SaveNewMapAsync() 공개 메소드

public SaveNewMapAsync ( Viewpoint initialViewpoint, string title, string description, string tags ) : System.Threading.Tasks.Task
initialViewpoint Viewpoint
title string
description string
tags string
리턴 System.Threading.Tasks.Task
        public async Task SaveNewMapAsync(Viewpoint initialViewpoint, string title, string description, string[] tags)
        {
            // Get the ArcGIS Online portal 
            ArcGISPortal agsOnline = await ArcGISPortal.CreateAsync(new Uri("https://www.arcgis.com/sharing/rest"));

            // Set the map's initial viewpoint using the extent (viewpoint) passed in
            _map.InitialViewpoint = initialViewpoint;

            // Save the current state of the map as a portal item in the user's default folder
            await _map.SaveAsAsync(agsOnline, null, title, description, tags, null);
        }

Usage Example

예제 #1
0
        // Handle the OnMapInfoEntered event from the item input UI
        // MapSavedEventArgs contains the title, description, and tags that were entered
        private async void MapItemInfoEntered(object sender, MapSavedEventArgs e)
        {
            try
            {
                // Get information entered by the user for the new portal item properties
                var title       = e.Title;
                var description = e.Description;
                var tags        = e.Tags;

                // Get the current extent
                var currentViewpoint = _mapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry);

                // Export the current map view for the item's thumbnail
                RuntimeImage thumbnailImg = await _mapView.ExportImageAsync();

                // See if the map has already been saved (has an associated portal item)
                if (!_mapViewModel.MapIsSaved)
                {
                    // Call a method on MapViewModel to save the map as a new portal item
                    await _mapViewModel.SaveNewMapAsync(currentViewpoint, title, description, tags, thumbnailImg);

                    // Report a successful save
                    UIAlertController alert = UIAlertController.Create("Saved map", "Saved " + title + " to ArcGIS Online", UIAlertControllerStyle.Alert);
                    alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                    PresentViewController(alert, true, null);
                }
                else
                {
                    // Map has previously been saved as a portal item, update it (title, description, and tags will remain the same)
                    _mapViewModel.UpdateMapItem();

                    // Report success
                    UIAlertController alert = UIAlertController.Create("Updated map", "Saved changes to " + title, UIAlertControllerStyle.Alert);
                    alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                    PresentViewController(alert, true, null);
                }
            }
            catch (Exception ex)
            {
                // Report save error
                UIAlertController alert = UIAlertController.Create("Error", ex.Message, UIAlertControllerStyle.Alert);
                alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                PresentViewController(alert, true, null);
            }
            finally
            {
                // Get rid of the item input controls
                if (_mapInfoUI != null)
                {
                    _mapInfoUI.Hide();
                    _mapInfoUI = null;
                }
            }
        }
All Usage Examples Of ArcGISRuntimeXamarin.Samples.AuthorEditSaveMap.MapViewModel::SaveNewMapAsync