private void Initialize() { try { // Define the Uri for the service feature table (US state polygons) Uri myServiceFeatureTable_Uri = new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/3"); // Create a new service feature table from the Uri ServiceFeatureTable myServiceFeatureTable = new ServiceFeatureTable(myServiceFeatureTable_Uri); // Create a new feature layer from the service feature table FeatureLayer myFeatureLayer = new FeatureLayer(myServiceFeatureTable) { // Set the rendering mode of the feature layer to be dynamic (needed for extrusion to work) RenderingMode = FeatureRenderingMode.Dynamic }; // Create a new simple line symbol for the feature layer SimpleLineSymbol mySimpleLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Black, 1); // Create a new simple fill symbol for the feature layer SimpleFillSymbol mysimpleFillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, Color.Blue, mySimpleLineSymbol); // Create a new simple renderer for the feature layer SimpleRenderer mySimpleRenderer = new SimpleRenderer(mysimpleFillSymbol); // Get the scene properties from the simple renderer RendererSceneProperties myRendererSceneProperties = mySimpleRenderer.SceneProperties; // Set the extrusion mode for the scene properties myRendererSceneProperties.ExtrusionMode = ExtrusionMode.AbsoluteHeight; // Set the initial extrusion expression myRendererSceneProperties.ExtrusionExpression = "[POP2007] / 10"; // Set the feature layer's renderer to the define simple renderer myFeatureLayer.Renderer = mySimpleRenderer; // Create a new scene with the topographic backdrop Scene myScene = new Scene(BasemapType.Topographic); // Set the scene view's scene to the newly create one _mySceneView.Scene = myScene; // Add the feature layer to the scene's operational layer collection myScene.OperationalLayers.Add(myFeatureLayer); // Create a new map point to define where to look on the scene view MapPoint myMapPoint = new MapPoint(-10974490, 4814376, 0, SpatialReferences.WebMercator); // Create a new orbit location camera controller using the map point and defined distance OrbitLocationCameraController myOrbitLocationCameraController = new OrbitLocationCameraController(myMapPoint, 20000000); // Set the scene view's camera controller to the orbit location camera controller _mySceneView.CameraController = myOrbitLocationCameraController; } catch (Exception ex) { // Something went wrong, display the error AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.SetTitle("Error"); alert.SetMessage(ex.Message); alert.Show(); } }
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; }