private void UpdateUIFromMapPoint(MapPoint startingPoint)
        {
            // Update the decimal degrees text
            DecimalDegreesTextField.Text =
                CoordinateFormatter.ToLatitudeLongitude(startingPoint, LatitudeLongitudeFormat.DecimalDegrees, 4);

            // Update the degrees, minutes, seconds text
            DmsTextField.Text = CoordinateFormatter.ToLatitudeLongitude(startingPoint,
                                                                        LatitudeLongitudeFormat.DegreesMinutesSeconds, 1);

            // Update the UTM text
            UtmTextField.Text = CoordinateFormatter.ToUtm(startingPoint, UtmConversionMode.NorthSouthIndicators, true);

            // Update the USNG text
            UsngTextField.Text = CoordinateFormatter.ToUsng(startingPoint, 4, true);

            // Clear existing graphics overlays
            MyMapView.GraphicsOverlays[0].Graphics.Clear();

            // Create a symbol to symbolize the point
            SimpleMarkerSymbol symbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.X, Colors.Yellow, 20);

            // Create the graphic
            Graphic symbolGraphic = new Graphic(startingPoint, symbol);

            // Add the graphic to the graphics overlay
            MyMapView.GraphicsOverlays[0].Graphics.Add(symbolGraphic);
        }
コード例 #2
0
        private void UpdateUiFromMapPoint(MapPoint selectedPoint)
        {
            if (selectedPoint == null)
            {
                return;
            }

            // Clear event subscriptions - prevents an infinite loop.
            _utmEntry.EditingDidBegin  -= InputValueChanged;
            _dmsEntry.EditingDidBegin  -= InputValueChanged;
            _ddEntry.EditingDidBegin   -= InputValueChanged;
            _usngEntry.EditingDidBegin -= InputValueChanged;

            try
            {
                // Update the decimal degrees text.
                _ddEntry.Text =
                    CoordinateFormatter.ToLatitudeLongitude(selectedPoint, LatitudeLongitudeFormat.DecimalDegrees, 4);

                // Update the degrees, minutes, seconds text.
                _dmsEntry.Text = CoordinateFormatter.ToLatitudeLongitude(selectedPoint,
                                                                         LatitudeLongitudeFormat.DegreesMinutesSeconds, 1);

                // Update the UTM text.
                _utmEntry.Text = CoordinateFormatter.ToUtm(selectedPoint, UtmConversionMode.NorthSouthIndicators, true);

                // Update the USNG text.
                _usngEntry.Text = CoordinateFormatter.ToUsng(selectedPoint, 4, true);

                // Clear existing graphics overlays.
                _myMapView.GraphicsOverlays[0].Graphics.Clear();

                // Create a symbol to symbolize the point.
                SimpleMarkerSymbol symbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.X, Color.Yellow, 20);

                // Create the graphic.
                Graphic symbolGraphic = new Graphic(selectedPoint, symbol);

                // Add the graphic to the graphics overlay.
                _myMapView.GraphicsOverlays[0].Graphics.Add(symbolGraphic);
            }
            catch (Exception ex)
            {
                // The coordinate is malformed, warn and return.
                UIAlertController alertController = UIAlertController.Create("There was a problem formatting coordinates.", ex.Message, UIAlertControllerStyle.Alert);
                alertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                PresentViewController(alertController, true, null);
            }

            // Restore event subscriptions.
            _utmEntry.EditingDidBegin  += InputValueChanged;
            _dmsEntry.EditingDidBegin  += InputValueChanged;
            _ddEntry.EditingDidBegin   += InputValueChanged;
            _usngEntry.EditingDidBegin += InputValueChanged;
        }
コード例 #3
0
        private void UpdateUIFromMapPoint(MapPoint selectedPoint)
        {
            try
            {
                // Check if the selected point can be formatted into coordinates.
                CoordinateFormatter.ToLatitudeLongitude(selectedPoint, LatitudeLongitudeFormat.DecimalDegrees, 0);
            }
            catch (Exception e)
            {
                // Check if the excpetion is because the coordinates are out of range.
                if (e.Message == "Invalid argument: coordinates are out of range")
                {
                    // Set all of the text fields to contain the error message.
                    DecimalDegreesTextField.Text = "Coordinates are out of range";
                    DmsTextField.Text            = "Coordinates are out of range";
                    UtmTextField.Text            = "Coordinates are out of range";
                    UsngTextField.Text           = "Coordinates are out of range";

                    // Clear the selectionss symbol.
                    MyMapView.GraphicsOverlays[0].Graphics.Clear();
                }
                return;
            }

            // Update the decimal degrees text
            DecimalDegreesTextField.Text =
                CoordinateFormatter.ToLatitudeLongitude(selectedPoint, LatitudeLongitudeFormat.DecimalDegrees, 4);

            // Update the degrees, minutes, seconds text
            DmsTextField.Text = CoordinateFormatter.ToLatitudeLongitude(selectedPoint,
                                                                        LatitudeLongitudeFormat.DegreesMinutesSeconds, 1);

            // Update the UTM text
            UtmTextField.Text = CoordinateFormatter.ToUtm(selectedPoint, UtmConversionMode.NorthSouthIndicators, true);

            // Update the USNG text
            UsngTextField.Text = CoordinateFormatter.ToUsng(selectedPoint, 4, true);

            // Clear existing graphics overlays
            MyMapView.GraphicsOverlays[0].Graphics.Clear();

            // Create a symbol to symbolize the point
            SimpleMarkerSymbol symbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.X, Color.Yellow, 20);

            // Create the graphic
            Graphic symbolGraphic = new Graphic(selectedPoint, symbol);

            // Add the graphic to the graphics overlay
            MyMapView.GraphicsOverlays[0].Graphics.Add(symbolGraphic);
        }
コード例 #4
0
        private void UpdateUIFromMapPoint(MapPoint startingPoint)
        {
            if (startingPoint == null)
            {
                return;
            }
            // Clear event subscriptions - prevents an infinite loop
            _utmUITextField.EditingDidBegin            -= InputValueChanged;
            _dmsUITextField.EditingDidBegin            -= InputValueChanged;
            _decimalDegreesUITextField.EditingDidBegin -= InputValueChanged;
            _usngUITextField.EditingDidBegin           -= InputValueChanged;

            // Update the decimal degrees text
            _decimalDegreesUITextField.Text =
                CoordinateFormatter.ToLatitudeLongitude(startingPoint, LatitudeLongitudeFormat.DecimalDegrees, 4);

            // Update the degrees, minutes, seconds text
            _dmsUITextField.Text = CoordinateFormatter.ToLatitudeLongitude(startingPoint,
                                                                           LatitudeLongitudeFormat.DegreesMinutesSeconds, 1);

            // Update the UTM text
            _utmUITextField.Text = CoordinateFormatter.ToUtm(startingPoint, UtmConversionMode.NorthSouthIndicators, true);

            // Update the USNG text
            _usngUITextField.Text = CoordinateFormatter.ToUsng(startingPoint, 4, true);

            // Clear existing graphics overlays
            _myMapView.GraphicsOverlays[0].Graphics.Clear();

            // Create a symbol to symbolize the point
            SimpleMarkerSymbol symbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.X, Color.Yellow, 20);

            // Create the graphic
            Graphic symbolGraphic = new Graphic(startingPoint, symbol);

            // Add the graphic to the graphics overlay
            _myMapView.GraphicsOverlays[0].Graphics.Add(symbolGraphic);

            // Restore event subscriptions
            _utmUITextField.EditingDidBegin            += InputValueChanged;
            _dmsUITextField.EditingDidBegin            += InputValueChanged;
            _decimalDegreesUITextField.EditingDidBegin += InputValueChanged;
            _usngUITextField.EditingDidBegin           += InputValueChanged;
        }
コード例 #5
0
        private void MapView_MouseMove(object sender, MouseEventArgs e)
        {
            if (null == FocusMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry))
            {
                return;
            }

            var screenLocation = e.GetPosition(FocusMapView);
            var location       = FocusMapView.ScreenToLocation(screenLocation);

            if (FocusMapView.IsWrapAroundEnabled)
            {
                location = (MapPoint)GeometryEngine.NormalizeCentralMeridian(location);
            }

            const int precision = 8;

            _viewModel.Wgs84 = CoordinateFormatter.ToLatitudeLongitude(location, LatitudeLongitudeFormat.DecimalDegrees, precision);
            _viewModel.Mgrs  = CoordinateFormatter.ToMgrs(location, MgrsConversionMode.Automatic, precision, true);
            _viewModel.Utm   = CoordinateFormatter.ToUtm(location, UtmConversionMode.NorthSouthIndicators, true);
        }