コード例 #1
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);
        }
コード例 #2
0
        private void ShowSaveMapUi()
        {
            if (_mapInfoUi != null)
            {
                return;
            }

            // Create a view to show map item info entry controls over the map view.
            nfloat topMargin = NavigationController.NavigationBar.Frame.Height + UIApplication.SharedApplication.StatusBarFrame.Height;
            var    ovBounds  = new CGRect(5, topMargin + 5, View.Bounds.Width - 10, View.Bounds.Height - topMargin - 45);

            _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);
        }
コード例 #3
0
 private void SaveCanceled(object sender, EventArgs e)
 {
     // Remove the item input UI.
     _mapInfoUi.Hide();
     _mapInfoUi = null;
 }
コード例 #4
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.
                string   title       = e.Title;
                string   description = e.Description;
                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 thumbnailImg = await _myMapView.ExportImageAsync();

                // 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, 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
                {
                    // 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.
                    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)
            {
                // 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();
            }
        }