예제 #1
0
        public async void Initialize()
        {
            // Create a new scene with basemap
            var myScene = new Scene(Basemap.CreateImageryWithLabels());

            // create an elevation source
            ArcGISTiledElevationSource elevationSrc = new ArcGISTiledElevationSource(_elevationSourceUrl);

            myScene.BaseSurface.ElevationSources.Add(elevationSrc);

            // create additional layer
            ArcGISSceneLayer sceneLayer = new ArcGISSceneLayer(_serviceUri);

            myScene.OperationalLayers.Add(sceneLayer);

            // Set the surface placement mode for the overlay.
            graphicsOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Relative;

            // create a red "X" marker symbol
            SimpleMarkerSceneSymbol car = new SimpleMarkerSceneSymbol(SimpleMarkerSceneSymbolStyle.Cube, Color.Red, 20, 20, 20, SceneSymbolAnchorPosition.Bottom);

            // create a new graphic; assign the point and the symbol in the constructor


            try
            {
                // Load the layer.
                await sceneLayer.LoadAsync();

                // Get the center of the scene layer.
                MapPoint center = (MapPoint)GeometryEngine.Project(sceneLayer.FullExtent.GetCenter(), SpatialReferences.Wgs84);
                Console.WriteLine(center.ToString());
                var newPoint = new MapPoint(_positionPublisher.getX(), _positionPublisher.getY(), 0, SpatialReferences.Wgs84);

                graphic.Geometry = newPoint;
                graphic.Symbol   = car;

                graphicsOverlay.Graphics.Add(graphic);
                MainWindow.View.Map3D.GraphicsOverlays.Add(graphicsOverlay);

                // Assign the Scene to the SceneView.
                MainWindow.View.Map3D.Scene = myScene;

                ////  CAMERA ANGLE ////
                // Create a camera with coordinates showing layer data.
                // Camera camera = new Camera(center.Y, center.X, 225, 220, 80, 0);
                // Set view point of scene view using camera.
                //await Map3D.SetViewpointCameraAsync(camera);

                // create an OrbitGeoElementCameraController, pass in the target graphic and initial camera distance
                var orbitGraphicController = new OrbitGeoElementCameraController(graphic, 1000);
                MainWindow.View.Map3D.CameraController = orbitGraphicController;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "Error");
            }
        }
        private async void Initialize()
        {
            try
            {
                // Create a new Scene with an imagery basemap.
                Scene myScene = new Scene(BasemapStyle.ArcGISImageryStandard);

                // Add the Scene to the SceneView.
                _mySceneView.Scene = myScene;

                // Create a new GraphicsOverlay and add it to the SceneView.
                GraphicsOverlay graphicsOverlay = new GraphicsOverlay();
                graphicsOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Relative;
                _mySceneView.GraphicsOverlays.Add(graphicsOverlay);

                // Call a function to create a new distance composite symbol with three ranges.
                DistanceCompositeSceneSymbol compositeSymbol = await CreateCompositeSymbol();

                // Create a new point graphic with the composite symbol, add it to the graphics overlay.
                MapPoint locationPoint = new MapPoint(-2.708471, 56.096575, 5000, SpatialReferences.Wgs84);
                Graphic  pointGraphic  = new Graphic(locationPoint, compositeSymbol);
                graphicsOverlay.Graphics.Add(pointGraphic);

                // Add an orbit camera controller to lock the camera to the graphic.
                OrbitGeoElementCameraController cameraController = new OrbitGeoElementCameraController(pointGraphic, 20)
                {
                    CameraPitchOffset   = 80,
                    CameraHeadingOffset = -30
                };
                _mySceneView.CameraController = cameraController;
            }
            catch (Exception e)
            {
                // Something went wrong, display the error
                AlertDialog.Builder alert = new AlertDialog.Builder(this);
                alert.SetTitle("Error");
                alert.SetMessage(e.Message);
                alert.Show();
            }
        }
예제 #3
0
        private async void Initialize()
        {
            try
            {
                // Create a new Scene with an imagery basemap.
                Scene myScene = new Scene(Basemap.CreateImagery());

                // Add the Scene to the SceneView.
                _mySceneView.Scene = myScene;

                // Create a new GraphicsOverlay and add it to the SceneView.
                GraphicsOverlay graphicsOverlay = new GraphicsOverlay();
                graphicsOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Relative;
                _mySceneView.GraphicsOverlays.Add(graphicsOverlay);

                // Call a function to create a new distance composite symbol with three ranges.
                DistanceCompositeSceneSymbol compositeSymbol = await CreateCompositeSymbol();

                // Create a new point graphic with the composite symbol, add it to the graphics overlay.
                MapPoint locationPoint = new MapPoint(-2.708471, 56.096575, 5000, SpatialReferences.Wgs84);
                Graphic  pointGraphic  = new Graphic(locationPoint, compositeSymbol);
                graphicsOverlay.Graphics.Add(pointGraphic);

                // Add an orbit camera controller to lock the camera to the graphic.
                OrbitGeoElementCameraController cameraController = new OrbitGeoElementCameraController(pointGraphic, 20)
                {
                    CameraPitchOffset   = 80,
                    CameraHeadingOffset = -30
                };
                _mySceneView.CameraController = cameraController;
            }
            catch (Exception e)
            {
                // Something went wrong, display the error.
                UIAlertController alert = UIAlertController.Create("Error", e.Message, UIAlertControllerStyle.Alert);
                alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                PresentViewController(alert, true, null);
            }
        }
예제 #4
0
        private async void Initialize()
        {
            try
            {
                // Create a new Scene with an imagery basemap.
                Scene myScene = new Scene(Basemap.CreateImagery());

                // Add the Scene to the SceneView.
                MySceneView.Scene = myScene;

                // Create a new GraphicsOverlay and add it to the SceneView.
                GraphicsOverlay graphicsOverlay = new GraphicsOverlay();
                graphicsOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Relative;
                MySceneView.GraphicsOverlays.Add(graphicsOverlay);

                // Call a function to create a new distance composite symbol with three ranges.
                DistanceCompositeSceneSymbol compositeSymbol = await CreateCompositeSymbol();

                // Create a new point graphic with the composite symbol, add it to the graphics overlay.
                MapPoint locationPoint = new MapPoint(-2.708471, 56.096575, 5000, SpatialReferences.Wgs84);
                Graphic  pointGraphic  = new Graphic(locationPoint, compositeSymbol);
                graphicsOverlay.Graphics.Add(pointGraphic);

                // Add an orbit camera controller to lock the camera to the graphic.
                OrbitGeoElementCameraController cameraController = new OrbitGeoElementCameraController(pointGraphic, 20)
                {
                    CameraPitchOffset   = 80,
                    CameraHeadingOffset = -30
                };
                MySceneView.CameraController = cameraController;
            }
            catch (Exception e)
            {
                var dialog = new MessageDialog2(e.ToString(), "Error");
                await dialog.ShowAsync();
            }
        }
        private async void Initialize()
        {
            // Create the scene with an imagery basemap.
            MySceneView.Scene = new Scene(Basemap.CreateImagery());

            // Add the elevation surface.
            ArcGISTiledElevationSource tiledElevationSource = new ArcGISTiledElevationSource(_elevationUri);
            Surface baseSurface = new Surface
            {
                ElevationSources = { tiledElevationSource }
            };

            MySceneView.Scene.BaseSurface = baseSurface;

            // Add buildings.
            ArcGISSceneLayer sceneLayer = new ArcGISSceneLayer(_buildingsUri);

            MySceneView.Scene.OperationalLayers.Add(sceneLayer);
            await sceneLayer.LoadAsync();

            // Configure the graphics overlay for the tank and add the overlay to the SceneView.
            _tankOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Relative;
            MySceneView.GraphicsOverlays.Add(_tankOverlay);

            // Configure the heading expression for the tank; this will allow the
            //     viewshed to update automatically based on the tank's position.
            SimpleRenderer renderer3D = new SimpleRenderer();

            renderer3D.SceneProperties.HeadingExpression = "[HEADING]";
            _tankOverlay.Renderer = renderer3D;

            try
            {
                // Create the tank graphic - get the model path.
                string modelPath = GetModelPath();
                // - Create the symbol and make it 10x larger (to be the right size relative to the scene).
                ModelSceneSymbol tankSymbol = await ModelSceneSymbol.CreateAsync(new Uri(modelPath), 10);

                // - Adjust the position.
                tankSymbol.Heading = 90;
                // - The tank will be positioned relative to the scene surface by its bottom.
                //     This ensures that the tank is on the ground rather than partially under it.
                tankSymbol.AnchorPosition = SceneSymbolAnchorPosition.Bottom;
                // - Create the graphic.
                _tank = new Graphic(new MapPoint(28.047199, -26.189105, SpatialReferences.Wgs84), tankSymbol);
                // - Update the heading.
                _tank.Attributes["HEADING"] = 0.0;
                // - Add the graphic to the overlay.
                _tankOverlay.Graphics.Add(_tank);

                // Create a viewshed for the tank.
                GeoElementViewshed geoViewshed = new GeoElementViewshed(
                    geoElement: _tank,
                    horizontalAngle: 90.0,
                    verticalAngle: 40.0,
                    minDistance: 0.1,
                    maxDistance: 250.0,
                    headingOffset: 0.0,
                    pitchOffset: 0.0)
                {
                    // Offset viewshed observer location to top of tank.
                    OffsetZ = 3.0
                };

                // Create the analysis overlay and add to the scene.
                AnalysisOverlay overlay = new AnalysisOverlay();
                overlay.Analyses.Add(geoViewshed);
                MySceneView.AnalysisOverlays.Add(overlay);

                // Create a camera controller to orbit the tank.
                OrbitGeoElementCameraController cameraController = new OrbitGeoElementCameraController(_tank, 200.0)
                {
                    CameraPitchOffset = 45.0
                };
                // - Apply the camera controller to the SceneView.
                MySceneView.CameraController = cameraController;

                // Create a timer; this will enable animating the tank.
                Device.StartTimer(new TimeSpan(0, 0, 0, 0, 60), () =>
                {
                    // Move the tank every time the timer elapses.
                    AnimateTank();
                    // Keep the timer running.
                    return(true);
                });

                // Allow the user to click to define a new destination.
                MySceneView.GeoViewTapped += (sender, args) => { _tankEndPoint = args.Location; };
            }
            catch (Exception e)
            {
                await Application.Current.MainPage.DisplayAlert("Error", e.ToString(), "OK");
            }
        }
        private async void Initialize()
        {
            // Apply appropriate maps to the scene and the inset map view
            InsetMapView.Map  = new Map(Basemap.CreateImagery());
            MySceneView.Scene = new Scene(Basemap.CreateImagery());

            // Update the mission selection UI
            MissionSelectionBox.ItemsSource   = _missionToItemId.Keys;
            MissionSelectionBox.SelectedIndex = 0;

            // Wire up the selection change event to call the ChangeMission method; this method resets the animation and starts a new mission
            MissionSelectionBox.SelectionChanged += async(sender, args) => { await ChangeMission(args.AddedItems[0].ToString()); };

            // Apply the elevation source
            Surface         surface         = new Surface();
            ElevationSource elevationSource = new ArcGISTiledElevationSource(_elevationServiceUrl);

            surface.ElevationSources.Add(elevationSource);
            MySceneView.Scene.BaseSurface = surface;

            // Create and add the graphics overlay
            GraphicsOverlay sceneOverlay = new GraphicsOverlay
            {
                SceneProperties = { SurfacePlacement = SurfacePlacement.Absolute }
            };

            MySceneView.GraphicsOverlays.Add(sceneOverlay);

            // Create a renderer to handle updating plane's orientation
            SimpleRenderer          renderer3D       = new SimpleRenderer();
            RendererSceneProperties renderProperties = renderer3D.SceneProperties;

            // Use expressions to keep the renderer properties updated as parameters of the rendered object
            renderProperties.HeadingExpression = "[HEADING]";
            renderProperties.PitchExpression   = "[PITCH]";
            renderProperties.RollExpression    = "[ROLL]";
            // Apply the renderer to the scene view's overlay
            sceneOverlay.Renderer = renderer3D;

            // Create renderer to symbolize plane and update plane orientation in the inset map
            SimpleRenderer renderer2D = new SimpleRenderer();
            // Create the symbol that will be used for the plane
            SimpleMarkerSymbol plane2DSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Triangle, System.Drawing.Color.Blue, 10);

            // Apply the symbol to the renderer
            renderer2D.Symbol = plane2DSymbol;
            // Apply a rotation expression to the renderer
            renderer2D.RotationExpression = "[ANGLE]";
            // Update the inset map with a new GraphicsOverlay based on the renderer
            GraphicsOverlay insetMapOverlay = new GraphicsOverlay
            {
                Renderer = renderer2D
            };

            InsetMapView.GraphicsOverlays.Add(insetMapOverlay);

            // Create placeholder graphic for showing the mission route in the inset map
            SimpleLineSymbol routeSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, System.Drawing.Color.Red, 2);

            _routeGraphic = new Graphic {
                Symbol = routeSymbol
            };
            insetMapOverlay.Graphics.Add(_routeGraphic);

            // Create the plane graphic; this is symbolized as a blue triangle because of renderer implemented above
            // Create the attribute dictionary
            Dictionary <string, object> plane2DAttributes = new Dictionary <string, object>();

            // Set the angle for the plane graphic
            plane2DAttributes["ANGLE"] = 0f;
            // Create the graphic from the attributes and the initial point
            _plane2D = new Graphic(new MapPoint(0, 0, SpatialReferences.Wgs84), plane2DAttributes);
            // Add the plane graphic to the inset map via the overlay
            insetMapOverlay.Graphics.Add(_plane2D);

            try
            {
                // Create the model graphic for the plane
                // Get the path to the 3D model
                string modelPath = GetModelPath();
                // Create the scene symbol from the path to the model
                ModelSceneSymbol plane3DSymbol = await ModelSceneSymbol.CreateAsync(new Uri(modelPath), 1.0);

                // Create the graphic with an initial location and the plane symbol
                _plane3D = new Graphic(new MapPoint(0, 0, 0, SpatialReferences.Wgs84), plane3DSymbol);
                // Add the plane to the overlay
                sceneOverlay.Graphics.Add(_plane3D);

                // Create the orbit camera controller to follow the plane
                _orbitCameraController = new OrbitGeoElementCameraController(_plane3D, 20.0)
                {
                    CameraPitchOffset = 75.0
                };
                MySceneView.CameraController = _orbitCameraController;

                // Create a timer; this will enable animating the plane
                _animationTimer = new DispatcherTimer()
                {
                    // This is the duration of the timer in milliseconds. This controls the animation speed (fps)
                    Interval = new TimeSpan(0, 0, 0, 0, 60)
                };

                _animationTimer.Tick += AnimatePlane;

                // Set the initial mission for when the sample loads
                await ChangeMission(_missionToItemId.Keys.First());
            }
            catch (Exception e)
            {
                await new MessageDialog(e.ToString(), "Error").ShowAsync();
            }
        }
예제 #7
0
        private async Task Initialize()
        {
            // Create the scene with an imagery basemap.
            _mySceneView.Scene = new Scene(Basemap.CreateImagery());

            // Add the elevation surface.
            ArcGISTiledElevationSource tiledElevationSource = new ArcGISTiledElevationSource(_elevationUri);
            Surface baseSurface = new Surface
            {
                ElevationSources = { tiledElevationSource }
            };

            _mySceneView.Scene.BaseSurface = baseSurface;

            // Add buildings.
            _mySceneView.Scene.OperationalLayers.Add(new ArcGISSceneLayer(_buildingsUri));

            // Configure the graphics overlay for the tank and add the overlay to the SceneView.
            _tankOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Relative;
            _mySceneView.GraphicsOverlays.Add(_tankOverlay);

            // Configure the heading expression for the tank; this will allow the
            //     viewshed to update automatically based on the tank's position.
            SimpleRenderer renderer3D = new SimpleRenderer();

            renderer3D.SceneProperties.HeadingExpression = "[HEADING]";
            _tankOverlay.Renderer = renderer3D;

            // Create the tank graphic - get the model path.
            string modelPath = GetModelPath();
            // - Create the symbol and make it 10x larger (to be the right size relative to the scene).
            ModelSceneSymbol tankSymbol = await ModelSceneSymbol.CreateAsync(new Uri(modelPath), 10);

            // - Adjust the position.
            tankSymbol.Heading = 90;
            // - The tank will be positioned relative to the scene surface by its bottom
            //       This ensures that the tank is on the ground rather than partially under it.
            tankSymbol.AnchorPosition = SceneSymbolAnchorPosition.Bottom;
            // - Create the graphic.
            _tank = new Graphic(new MapPoint(-4.506390, 48.385624, SpatialReferences.Wgs84), tankSymbol);
            // - Update the heading.
            _tank.Attributes["HEADING"] = 0.0;
            // - Add the graphic to the overlay.
            _tankOverlay.Graphics.Add(_tank);

            // Create a viewshed for the tank.
            GeoElementViewshed geoViewshed = new GeoElementViewshed(
                geoElement: _tank,
                horizontalAngle: 90.0,
                verticalAngle: 40.0,
                minDistance: 0.1,
                maxDistance: 250.0,
                headingOffset: 0.0,
                pitchOffset: 0.0)
            {
                // Offset viewshed observer location to top of tank.
                OffsetZ = 3.0
            };

            // Create the analysis overlay and add to the scene.
            AnalysisOverlay overlay = new AnalysisOverlay();

            overlay.Analyses.Add(geoViewshed);
            _mySceneView.AnalysisOverlays.Add(overlay);

            // Create a camera controller to orbit the tank.
            OrbitGeoElementCameraController cameraController = new OrbitGeoElementCameraController(_tank, 200.0)
            {
                CameraPitchOffset = 45.0
            };

            // - Apply the camera controller to the SceneView.
            _mySceneView.CameraController = cameraController;

            // Create a timer; this will enable animating the tank.
            Timer animationTimer = new Timer(60)
            {
                Enabled   = true,
                AutoReset = true
            };

            // - Move the tank every time the timer expires.
            animationTimer.Elapsed += (o, e) =>
            {
                AnimateTank();
            };
            // - Start the timer.
            animationTimer.Start();

            // Allow the user to click to define a new destination.
            _mySceneView.GeoViewTapped += (sender, args) => { _tankEndPoint = args.Location; };
        }
        private async void Initialize()
        {
            // Create a scene.
            Scene myScene = new Scene(Basemap.CreateImageryWithLabels());

            // Create a surface for elevation data.
            Surface surface = new Surface();

            surface.ElevationSources.Add(new ArcGISTiledElevationSource(_elevationUri));

            // Add the surface to the scene.
            myScene.BaseSurface = surface;

            // Create a graphics overlay for the scene.
            GraphicsOverlay sceneGraphicsOverlay = new GraphicsOverlay()
            {
                SceneProperties = new LayerSceneProperties(SurfacePlacement.Absolute)
            };

            MySceneView.GraphicsOverlays.Add(sceneGraphicsOverlay);

            // Location at the crater.
            MapPoint craterLocation = new MapPoint(-109.929589, 38.437304, 1700, SpatialReferences.Wgs84);

            // Create the plane symbol and make it 10x larger (to be the right size relative to the scene).
            ModelSceneSymbol planeSymbol;

            try
            {
                planeSymbol = await ModelSceneSymbol.CreateAsync(_modelUri, 10.0);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                await Application.Current.MainPage.DisplayAlert("Error", "Loading plane model failed. Sample failed to initialize.", "OK");

                return;
            }

            // Create a graphic using the plane symbol.
            Graphic planeGraphic = new Graphic(new MapPoint(craterLocation.X, craterLocation.Y, 5000.0, SpatialReferences.Wgs84), planeSymbol);

            sceneGraphicsOverlay.Graphics.Add(planeGraphic);

            // Instantiate a new camera controller which orbits a geo element.
            _orbitPlaneCameraController = new OrbitGeoElementCameraController(planeGraphic, 300.0)
            {
                CameraPitchOffset   = 30,
                CameraHeadingOffset = 150
            };

            // Instantiate a new camera controller which orbits a location.
            _orbitCraterCameraController = new OrbitLocationCameraController(craterLocation, 6000.0)
            {
                CameraPitchOffset   = 3,
                CameraHeadingOffset = 150
            };

            // Set the starting camera controller.
            MySceneView.CameraController = _orbitPlaneCameraController;

            // Add the scene to the view.
            MySceneView.Scene = myScene;
        }
예제 #9
0
        private async void Initialize()
        {
            _statsVC = new StatsDisplayViewController();

            // Apply appropriate maps to the scene and the inset map view.
            _insetMapView.Map = new Map(Basemap.CreateImagery());
            _insetMapView.IsAttributionTextVisible = false;
            _mySceneView.Scene = new Scene(Basemap.CreateImagery());

            // Apply the elevation source.
            Surface         surface         = new Surface();
            ElevationSource elevationSource = new ArcGISTiledElevationSource(_elevationServiceUrl);

            surface.ElevationSources.Add(elevationSource);
            _mySceneView.Scene.BaseSurface = surface;

            // Create and add the graphics overlay.
            GraphicsOverlay sceneOverlay = new GraphicsOverlay
            {
                SceneProperties = { SurfacePlacement = SurfacePlacement.Absolute }
            };

            _mySceneView.GraphicsOverlays.Add(sceneOverlay);

            // Create a renderer to handle updating plane's orientation.
            SimpleRenderer          renderer3D       = new SimpleRenderer();
            RendererSceneProperties renderProperties = renderer3D.SceneProperties;

            // Use expressions to keep the renderer properties updated as parameters of the rendered object.
            renderProperties.HeadingExpression = "[HEADING]";
            renderProperties.PitchExpression   = "[PITCH]";
            renderProperties.RollExpression    = "[ROLL]";

            // Apply the renderer to the scene view's overlay.
            sceneOverlay.Renderer = renderer3D;

            // Create renderer to symbolize plane and update plane orientation in the inset map.
            SimpleRenderer renderer2D = new SimpleRenderer
            {
                Symbol             = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Triangle, Color.Blue, 10),
                RotationExpression = "[ANGLE]"
            };

            // Update the inset map with a new GraphicsOverlay based on the renderer.
            GraphicsOverlay insetMapOverlay = new GraphicsOverlay
            {
                Renderer = renderer2D
            };

            _insetMapView.GraphicsOverlays.Add(insetMapOverlay);

            // Create placeholder graphic for showing the mission route in the inset map.
            SimpleLineSymbol routeSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Red, 2);

            _routeGraphic = new Graphic {
                Symbol = routeSymbol
            };
            insetMapOverlay.Graphics.Add(_routeGraphic);

            // Create the plane graphic; this is symbolized as a blue triangle because of renderer implemented above.
            Dictionary <string, object> plane2DAttributes = new Dictionary <string, object>
            {
                // Set the angle for the plane graphic.
                ["ANGLE"] = 0f
            };

            // Create the graphic from the attributes and the initial point.
            _plane2D = new Graphic(new MapPoint(0, 0, SpatialReferences.Wgs84), plane2DAttributes);

            // Add the plane graphic to the inset map via the overlay.
            insetMapOverlay.Graphics.Add(_plane2D);

            try
            {
                // Create the model graphic for the plane.
                string modelPath = DataManager.GetDataFolder("681d6f7694644709a7c830ec57a2d72b", "Bristol.dae");

                // Create the scene symbol from the path to the model.
                ModelSceneSymbol plane3DSymbol = await ModelSceneSymbol.CreateAsync(new Uri(modelPath), 1.0);

                // Create the graphic with an initial location and the plane symbol.
                _plane3D = new Graphic(new MapPoint(0, 0, 0, SpatialReferences.Wgs84), plane3DSymbol);

                // Add the plane to the overlay.
                sceneOverlay.Graphics.Add(_plane3D);

                // Create the orbit camera controller to follow the plane.
                _orbitCameraController = new OrbitGeoElementCameraController(_plane3D, 20.0)
                {
                    CameraPitchOffset = 75.0
                };
                _mySceneView.CameraController = _orbitCameraController;

                // Create a timer; this animates the plane.
                // The value is the duration of the timer in milliseconds. This controls the speed of the animation (fps).
                _animationTimer = new Timer(60)
                {
                    AutoReset = true
                };

                // Set the initial mission for when the sample loads.
                ChangeMission(_missionToItemId.Keys.First());
            }
            catch (Exception e)
            {
                new UIAlertView("Error", e.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show();
            }
        }
예제 #10
0
        private async Task Initialize()
        {
            // Apply appropriate maps to the scene and the inset map view
            _insetMapView.Map = new Map(Basemap.CreateImagery());
            _insetMapView.IsAttributionTextVisible = false;
            _mySceneView.Scene = new Scene(Basemap.CreateImagery());

            // Apply the elevation source
            Surface         surface         = new Surface();
            ElevationSource elevationSource = new ArcGISTiledElevationSource(_elevationServiceUrl);

            surface.ElevationSources.Add(elevationSource);
            _mySceneView.Scene.BaseSurface = surface;

            // Create and add the graphics overlay
            GraphicsOverlay sceneOverlay = new GraphicsOverlay
            {
                SceneProperties = { SurfacePlacement = SurfacePlacement.Absolute }
            };

            _mySceneView.GraphicsOverlays.Add(sceneOverlay);

            // Create a renderer to handle updating plane's orientation
            SimpleRenderer          renderer3D       = new SimpleRenderer();
            RendererSceneProperties renderProperties = renderer3D.SceneProperties;

            // Use expressions to keep the renderer properties updated as parameters of the rendered object
            renderProperties.HeadingExpression = "[HEADING]";
            renderProperties.PitchExpression   = "[PITCH]";
            renderProperties.RollExpression    = "[ROLL]";
            // Apply the renderer to the scene view's overlay
            sceneOverlay.Renderer = renderer3D;

            // Create renderer to symbolize plane and update plane orientation in the inset map
            SimpleRenderer renderer2D = new SimpleRenderer();
            // Create the symbol that will be used for the plane
            SimpleMarkerSymbol plane2DSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Triangle, Color.Blue, 10);

            // Apply the symbol to the renderer
            renderer2D.Symbol = plane2DSymbol;
            // Apply a rotation expression to the renderer
            renderer2D.RotationExpression = "[ANGLE]";
            // Update the inset map with a new GraphicsOverlay based on the renderer
            GraphicsOverlay insetMapOperlay = new GraphicsOverlay
            {
                Renderer = renderer2D
            };

            _insetMapView.GraphicsOverlays.Add(insetMapOperlay);

            // Create placeholder graphic for showing the mission route in the inset map
            SimpleLineSymbol routeSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Red, 2);

            _routeGraphic = new Graphic {
                Symbol = routeSymbol
            };
            insetMapOperlay.Graphics.Add(_routeGraphic);

            // Create the plane graphic; this is symbolized as a blue triangle because of renderer implemented above
            // Create the attribute dictionary
            Dictionary <string, object> plane2DAttributes = new Dictionary <string, object>();

            // Set the angle for the plane graphic
            plane2DAttributes["ANGLE"] = 0f;
            // Create the graphic from the attributes and the initial point
            _plane2D = new Graphic(new MapPoint(0, 0, SpatialReferences.Wgs84), plane2DAttributes);
            // Add the plane graphic to the inset map via the overlay
            insetMapOperlay.Graphics.Add(_plane2D);

            // Create the model graphic for the plane
            // Get the path to the 3D model
            string modelPath = await GetModelPath();

            // Create the scene symbol from the path to the model
            ModelSceneSymbol plane3DSymbol = await ModelSceneSymbol.CreateAsync(new Uri(modelPath), 1.0);

            // Create the graphic with an initial location and the plane symbol
            _plane3D = new Graphic(new MapPoint(0, 0, 0, SpatialReferences.Wgs84), plane3DSymbol);
            // Add the plane to the overlay
            sceneOverlay.Graphics.Add(_plane3D);

            // Create the orbit camera controller to follow the plane
            _orbitCameraController = new OrbitGeoElementCameraController(_plane3D, 20.0)
            {
                CameraPitchOffset = 75.0
            };
            _mySceneView.CameraController = _orbitCameraController;

            // Create a timer; this animates the plane
            // The value is the duration of the timer in milliseconds. This controls the speed of the animation (fps)
            _animationTimer = new Timer(60)
            {
                AutoReset = true
            };

            // Call the animation method every time the timer expires (once every 60ms per above)
            _animationTimer.Elapsed += (sender, args) => AnimatePlane();

            // Set the initial mission for when the sample loads
            await ChangeMission(_missionToItemId.Keys.First());
        }