Ejemplo n.º 1
0
        private async void DistanceAzimuthItem_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var line = await RequestUserShape(DrawShape.LineSegment, _lineSymbol) as Polyline;

                // Requesting shape canceled
                if (line == null)
                {
                    return;
                }

                var parameters = new MensurationLengthParameters()
                {
                    AngularUnit = comboAngularUnit.SelectedItem as AngularUnit,
                    LinearUnit  = comboLinearUnit.SelectedItem as LinearUnit
                };

                var result = await _mensurationTask.DistanceAndAngleAsync(
                    line.Parts.First().StartPoint,
                    line.Parts.First().EndPoint, parameters);

                ShowResults(result, ((MenuFlyoutItem)sender).Text);
            }
            catch (Exception ex)
            {
                var _ = new MessageDialog(ex.Message, "Sample Error").ShowAsync();
            }
        }
Ejemplo n.º 2
0
        private async void OnMeasureCommand(object param)
        {
            if (_editState == EditState.None && _mapView != null && !_mapView.Editor.IsActive)
            {
                _lineSymbol = new SimpleLineSymbol()
                {
                    Color = Colors.Red, Style = SimpleLineStyle.Solid, Width = 2
                } as Symbol;

                _graphicsOverlay = _mapView.GraphicsOverlays["graphicsOverlay"];

                // World Topo Map doesn't support mensuration
                //var temp = _mapView.Map.Layers["World Topo Map"];
                var temp = _mapView.Map.Layers["MensurationMapServiceLayer"];

                _mensurationTask = new MensurationTask(new Uri((temp as ArcGISTiledMapServiceLayer).ServiceUri));

                // lets do a basic distance measure
                try
                {
                    var line = await RequestUserShape(DrawShape.LineSegment, _lineSymbol) as Polyline;

                    // Requesting shape cancelled
                    if (line == null)
                    {
                        return;
                    }

                    var parameters = new MensurationLengthParameters()
                    {
                        AngularUnit = AngularUnits.Degrees,
                        LinearUnit  = LinearUnits.Meters
                    };

                    var result = await _mensurationTask.DistanceAndAngleAsync(
                        line.Parts.First().StartPoint,
                        line.Parts.First().EndPoint, parameters);

                    if (result.Distance != null)
                    {
                        ShowResults(result, "Measure results");
                    }
                    else
                    {
                        MessageBox.Show("Error", "Mensuration Error");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Mensuration Error");
                }
                finally
                {
                    _graphicsOverlay.Graphics.Clear();
                }
            }
        }
Ejemplo n.º 3
0
        private async void DistanceAzimuthButton_Click(object sender, RoutedEventArgs e)
        {
            var line = await RequestUserShape(DrawShape.LineSegment, _lineSymbol) as Polyline;

            try
            {
                MapPoint pointOne = new MapPoint(line.Paths[0][0], mapView.SpatialReference);
                MapPoint pointTwo = new MapPoint(line.Paths[0][1], mapView.SpatialReference);

                var parameters = new MensurationLengthParameters()
                {
                    AngularUnit = comboAngularUnit.SelectedItem as AngularUnit,
                    LinearUnit  = comboLinearUnit.SelectedItem as LinearUnit
                };

                var result = await _mensurationTask.DistanceAndAngleAsync(pointOne, pointTwo, parameters);

                ShowResults(result, ((Button)sender).Tag.ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Mensuration Error");
            }
        }
        private async void DistanceAzimuthItem_Click(object sender, RoutedEventArgs e)
        {
            try
            {
				var line = await RequestUserShape(DrawShape.LineSegment, _lineSymbol) as Polyline;
		
				// Requesting shape canceled
				if (line == null)
					return;

                var parameters = new MensurationLengthParameters()
                {
                    AngularUnit = comboAngularUnit.SelectedItem as AngularUnit,
                    LinearUnit = comboLinearUnit.SelectedItem as LinearUnit
                };

				var result = await _mensurationTask.DistanceAndAngleAsync(
					line.Parts.First().StartPoint,
					line.Parts.First().EndPoint, parameters);	
				ShowResults(result, ((MenuFlyoutItem)sender).Text);
            }
            catch (Exception ex)
            {
				var _ = new MessageDialog(ex.Message, "Sample Error").ShowAsync();
            }
        }
        private async void OnMeasureCommand(object param)
        {
            if (_editState == EditState.None && _mapView != null && !_mapView.Editor.IsActive)
            {
                _lineSymbol = new SimpleLineSymbol() { Color = Colors.Red, Style = SimpleLineStyle.Solid, Width = 2 } as Symbol;

                _graphicsOverlay = _mapView.GraphicsOverlays["graphicsOverlay"];

                // World Topo Map doesn't support mensuration
                //var temp = _mapView.Map.Layers["World Topo Map"];
                var temp = _mapView.Map.Layers["MensurationMapServiceLayer"];

                _mensurationTask = new MensurationTask(new Uri((temp as ArcGISTiledMapServiceLayer).ServiceUri));

                // lets do a basic distance measure
                try
                {
                    var line = await RequestUserShape(DrawShape.LineSegment, _lineSymbol) as Polyline;

                    // Requesting shape cancelled
                    if (line == null)
                        return;

                    var parameters = new MensurationLengthParameters()
                    {
                        AngularUnit = AngularUnits.Degrees,
                        LinearUnit = LinearUnits.Meters
                    };

                    var result = await _mensurationTask.DistanceAndAngleAsync(
                        line.Parts.First().StartPoint,
                        line.Parts.First().EndPoint, parameters);

                    if (result.Distance != null)
                    {
                        ShowResults(result, "Measure results");
                    }
                    else
                    {
                        MessageBox.Show("Error", "Mensuration Error");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Mensuration Error");
                }
                finally
                {
                    _graphicsOverlay.Graphics.Clear();
                }
            }
        }
        private async void DistanceAzimuthButton_Click(object sender, RoutedEventArgs e)
        {
            var line = await RequestUserShape(DrawShape.LineSegment, _lineSymbol) as Polyline;

            try
            {
                MapPoint pointOne = new MapPoint(line.Paths[0][0], mapView.SpatialReference);
                MapPoint pointTwo = new MapPoint(line.Paths[0][1], mapView.SpatialReference);

                var parameters = new MensurationLengthParameters()
                {
                    AngularUnit = comboAngularUnit.SelectedItem as AngularUnit,
                    LinearUnit = comboLinearUnit.SelectedItem as LinearUnit
                };

                var result = await _mensurationTask.DistanceAndAngleAsync(pointOne, pointTwo, parameters);
                ShowResults(result, ((Button)sender).Tag.ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Mensuration Error");
            }
        }