UpdateMapItem() 공개 메소드

public UpdateMapItem ( ) : void
리턴 void
예제 #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;
                }
            }
        }
        private async void OnSaveMapClicked(object sender, EventArgs 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");

                try
                {
                    // Call GetCredentialAsync on the AuthenticationManager to invoke the challenge handler
                    await AuthenticationManager.Current.GetCredentialAsync(challengeRequest, false);
                }
                catch (System.OperationCanceledException)
                {
                    // user canceled the login
                    throw new Exception("Portal log in was canceled.");
                }

                // See if the map has already been saved
                if (!_mapViewModel.MapIsSaved)
                {
                    // Map has not been saved ... save to portal for the first time
                    ShowSaveMapDialog();
                }
                else
                {
                    // Map has previously been saved as a portal item, update it (title and description will remain the same)
                    _mapViewModel.UpdateMapItem();

                    // Report a successful update
                    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
                    dialogBuilder.SetTitle("Map Updated!");
                    dialogBuilder.SetMessage("Changes to map ('" + _mapViewModel.Map.Item.Title + "' were saved to ArcGIS Online");
                    dialogBuilder.Show();
                }
            }
            catch (System.OperationCanceledException)
            {
                // user canceled the login
            }
        }
예제 #3
0
        // 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");
            }
        }