コード例 #1
0
        private async Task DrawEllipse()
        {
            try
            {
                while (MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry).TargetGeometry.Extent != null)
                {
                    // Accept user point
                    MapPoint userpoint = await MyMapView.Editor.RequestPointAsync() as MapPoint;

                    MapPoint point = GeometryEngine.NormalizeCentralMeridian(userpoint) as MapPoint;

                    // create the geodesic ellipse
                    var radius1   = (double)comboRadius1.SelectedItem;
                    var radius2   = (double)comboRadius2.SelectedItem;
                    var axis      = sliderAxis.Value;
                    var maxLength = (double)comboSegmentLength.SelectedItem;
                    var param     = new GeodesicEllipseParameters(point, radius1, radius2, LinearUnits.Miles)
                    {
                        AxisDirection    = axis,
                        MaxPointCount    = 10000,
                        MaxSegmentLength = maxLength
                    };
                    var ellipse = GeometryEngine.GeodesicEllipse(param);

                    //show geometries on map
                    _graphicsOverlay.Graphics.Clear();
                    _graphicsOverlay.Graphics.Add(new Graphic(point, _pinSymbol));
                    _graphicsOverlay.Graphics.Add(new Graphic(ellipse));

                    // geodesic sector
                    if ((bool)chkSector.IsChecked)
                    {
                        var sectorParams = new GeodesicSectorParameters(point, radius1, radius2, LinearUnits.Miles)
                        {
                            AxisDirection    = axis,
                            MaxPointCount    = 10000,
                            MaxSegmentLength = maxLength,
                            SectorAngle      = sliderSectorAxis.Value,
                            StartDirection   = sliderSectorStart.Value
                        };
                        var sector = GeometryEngine.GeodesicSector(sectorParams);

                        _graphicsOverlay.Graphics.Add(new Graphic(sector, _sectorSymbol));
                    }
                }
            }
            catch (TaskCanceledException) { }
            catch (Exception ex)
            {
                var _x = new MessageDialog(ex.Message, "Error").ShowAsync();
            }
        }
コード例 #2
0
        private async void EllipseButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                while (mapView.Extent != null)
                {
                    // Accept user point
                    var point = await mapView.Editor.RequestPointAsync();

                    // create the geodesic ellipse
                    var radius1   = (double)comboRadius1.SelectedItem;
                    var radius2   = (double)comboRadius2.SelectedItem;
                    var axis      = sliderAxis.Value;
                    var maxLength = (double)comboSegmentLength.SelectedItem;
                    var param     = new GeodesicEllipseParameters(point, radius1, radius2, LinearUnits.Miles)
                    {
                        AxisDirection    = axis,
                        MaxPointCount    = 10000,
                        MaxSegmentLength = maxLength
                    };
                    var ellipse = GeometryEngine.GeodesicEllipse(param);

                    //show geometries on map
                    _graphicsLayer.Graphics.Clear();
                    _graphicsLayer.Graphics.Add(new Graphic(point, _pinSymbol));
                    _graphicsLayer.Graphics.Add(new Graphic(ellipse));

                    // geodesic sector
                    if ((bool)chkSector.IsChecked)
                    {
                        var sectorParams = new GeodesicSectorParameters(point, radius1, radius2, LinearUnits.Miles)
                        {
                            AxisDirection    = axis,
                            MaxPointCount    = 10000,
                            MaxSegmentLength = maxLength,
                            SectorAngle      = sliderSectorAxis.Value,
                            StartDirection   = sliderSectorStart.Value
                        };
                        var sector = GeometryEngine.GeodesicSector(sectorParams);

                        _graphicsLayer.Graphics.Add(new Graphic(sector, _sectorSymbol));
                    }
                }
            }
            catch (TaskCanceledException)
            {
            }
            catch (Exception ex)
            {
                var _ = new MessageDialog(ex.Message, "Sample Error").ShowAsync();
            }
        }