예제 #1
0
        private void OnViewpointChanged(object sender, EventArgs e)
        {
            // Get the MapView or SceneView that sent the event
            GeoView sendingView = (GeoView)sender;

            // Only take action if this geoview is the one that the user is navigating.
            // Viewpoint changed events are fired when SetViewpoint is called; This check prevents a feedback loop
            if (sendingView.IsNavigating)
            {
                // If the MapView sent the event, update the SceneView's viewpoint
                if (sender is MapView)
                {
                    // Get the viewpoint
                    Viewpoint updateViewpoint = MyMapView.GetCurrentViewpoint(ViewpointType.CenterAndScale);

                    // Set the viewpoint
                    MySceneView.SetViewpoint(updateViewpoint);
                }
                else // Else, update the MapView's viewpoint
                {
                    // Get the viewpoint
                    Viewpoint updateViewpoint = MySceneView.GetCurrentViewpoint(ViewpointType.CenterAndScale);

                    // Set the viewpoint
                    MyMapView.SetViewpoint(updateViewpoint);
                }
            }
        }
예제 #2
0
        private async void MySceneView_MouseLeftDown(object sender, MouseEventArgs e)
        {
            if (edit == true && (type == "line" || type == "area"))
            {
                if (MySceneView.GetCurrentViewpoint(ViewpointType.BoundingGeometry) == null)
                {
                    return;
                }
                _mapViewModel.Clear(type);
                System.Windows.Point screenPoint = e.GetPosition(MySceneView);
                MapPoint             mapPoint    = await MySceneView.ScreenToLocationAsync(screenPoint);

                if (mapPoint.X != 0 && mapPoint.Y != 0 && mapPoint.Z != 0)
                {
                    mapPoint = GeometryEngine.NormalizeCentralMeridian(mapPoint) as MapPoint;
                    mapPoint_list.Add(new MapPoint(mapPoint.X, mapPoint.Y));
                    if (mapPoint_list.Count > 1)
                    {
                        var boatPositions = new PolylineBuilder(SpatialReferences.Wgs84);
                        boatPositions.AddPoint(new MapPoint(mapPoint_list[mapPoint_list.Count - 2].X, mapPoint_list[mapPoint_list.Count - 2].Y));
                        boatPositions.AddPoint(new MapPoint(mapPoint_list[mapPoint_list.Count - 1].X, mapPoint_list[mapPoint_list.Count - 1].Y));
                        var boatRoute = boatPositions.ToGeometry();
                        _mapViewModel.Line(boatRoute, "temp");;
                    }
                }
            }
        }
        private void addGraphics()
        {
            //var camera = new Camera(28.4, 83, 20000, 10, 70, 300)
            //var x = camera.Location.X - 0.01;
            //var y = camera.Location.Y- 0.25;
            var type   = new ViewpointType();
            var extent = MySceneView.GetCurrentViewpoint(type).TargetGeometry.Extent;

            var x = extent.XMin - 0.01;
            var y = extent.YMax + 0.25;

            for (int i = 0; i < 6; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    double   valueX   = x + i * (squareSize + spacing);
                    double   valueY   = y + j * (squareSize + spacing);
                    MapPoint mapPoint = new MapPoint(valueX, valueY);
                    Geometry polygon  = polygonForStartingPoint(mapPoint);
                    addGraphicsForPolygon(polygon);
                }
            }
        }
예제 #4
0
        private async Task QueryElevation(MapPoint location)
        {
            if (MySceneView.GetCurrentViewpoint(ViewpointType.BoundingGeometry) == null)
            {
                return;
            }

            if (!_isSceneReady)
            {
                return;
            }

            try
            {
                _isSceneReady = false;

                double elevation = await _fileElevationSource.GetElevationAsync(location);

                if (elevation.ToString() == "NaN")
                {
                    mapTip.Visibility = System.Windows.Visibility.Hidden;
                    return;
                }

                MapView.SetViewOverlayAnchor(mapTip, location);
                mapTip.Visibility = System.Windows.Visibility.Visible;
                txtElevation.Text = String.Format("Elevation: {0} meters", elevation.ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error retrieving elevation values: " + ex.Message, "Sample Error");
            }
            finally
            {
                _isSceneReady = true;
            }
        }