Exemple #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)
        {
            // Get the current map
            var myMap = _myMapView.Map;

            try
            {
                // Show the activity indicator so the user knows work is happening
                _activityIndicator.StartAnimating();

                // Get information entered by the user for the new portal item properties
                var title       = e.Title;
                var description = e.Description;
                var tags        = e.Tags;

                // 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)
                {
                    // Call a function to save the map as a new portal item
                    await SaveNewMapAsync(myMap, title, description, tags);

                    // 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
                {
                    // This is not the initial save, call SaveAsync to save changes to the existing portal item
                    await myMap.SaveAsync();

                    // Report update was successful
                    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", "Unable to save " + e.Title, UIAlertControllerStyle.Alert);
                alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                PresentViewController(alert, true, null);
            }
            finally
            {
                // Get rid of the item input controls
                _mapInfoUI.Hide();
                _mapInfoUI = null;

                // Hide the progress bar
                _activityIndicator.StopAnimating();
            }
        }
Exemple #2
0
        private void ShowSaveMapUI()
        {
            if (_mapInfoUI != null)
            {
                return;
            }

            // Create a view to show map item info entry controls over the map view
            var ovBounds = new CoreGraphics.CGRect(0, 60, View.Bounds.Width, View.Bounds.Height - 60);

            _mapInfoUI = new SaveMapDialogOverlay(ovBounds, 0.75f, UIColor.White, (PortalItem)_myMapView.Map.Item);

            // Handle the OnMapInfoEntered event to get the info entered by the user
            _mapInfoUI.OnMapInfoEntered += MapItemInfoEntered;

            // Handle the cancel event when the user closes the dialog without choosing to save
            _mapInfoUI.OnCanceled += SaveCanceled;

            // Add the map item info UI view (will display semi-transparent over the map view)
            View.Add(_mapInfoUI);
        }
Exemple #3
0
 private void SaveCanceled(object sender, EventArgs e)
 {
     // Remove the item input UI
     _mapInfoUI.Hide();
     _mapInfoUI = null;
 }