private void Initialize() { // Create the scene. _mySceneView.Scene = new Scene(BasemapStyle.ArcGISImageryStandard); // Get the path to the elevation raster. string packagePath = DataManager.GetDataFolder("98092369c4ae4d549bbbd45dba993ebc", "MontereyElevation.dt2"); // Create the elevation source from a list of paths. RasterElevationSource elevationSource = new RasterElevationSource(new[] { packagePath }); // Create a surface to display the elevation source. Surface elevationSurface = new Surface(); // Add the elevation source to the surface. elevationSurface.ElevationSources.Add(elevationSource); // Add the surface to the scene. _mySceneView.Scene.BaseSurface = elevationSurface; // Set an initial camera viewpoint. Camera camera = new Camera(36.51, -121.80, 300.0, 0, 70.0, 0.0); _mySceneView.SetViewpointCamera(camera); }
private void Initialize() { // Create the scene. _mySceneView.Scene = new Scene(BasemapStyle.ArcGISImageryStandard); // Get the path to the elevation tile package. string packagePath = DataManager.GetDataFolder("cce37043eb0440c7a5c109cf8aad5500", "MontereyElevation.tpk"); // Create the elevation source from the tile cache. TileCache elevationCache = new TileCache(packagePath); ArcGISTiledElevationSource elevationSource = new ArcGISTiledElevationSource(elevationCache); // Create a surface to display the elevation source. Surface elevationSurface = new Surface(); // Add the elevation source to the surface. elevationSurface.ElevationSources.Add(elevationSource); // Add the surface to the scene. _mySceneView.Scene.BaseSurface = elevationSurface; // Set an initial camera viewpoint. Camera camera = new Camera(36.525, -121.80, 300.0, 180, 80.0, 0.0); _mySceneView.SetViewpointCamera(camera); }
private void Initialize() { // Create a scene with elevation. Surface sceneSurface = new Surface(); sceneSurface.ElevationSources.Add(new ArcGISTiledElevationSource(_worldElevationService)); Scene myScene = new Scene(Basemap.CreateTopographic()) { BaseSurface = sceneSurface }; // Create and add a building layer. ArcGISSceneLayer buildingsLayer = new ArcGISSceneLayer(_buildingService); myScene.OperationalLayers.Add(buildingsLayer); // Create and add an analysis overlay. AnalysisOverlay measureAnalysisOverlay = new AnalysisOverlay(); _mySceneView.AnalysisOverlays.Add(measureAnalysisOverlay); // Create an initial distance measurement and show it. MapPoint start = new MapPoint(-4.494677, 48.384472, 24.772694, SpatialReferences.Wgs84); MapPoint end = new MapPoint(-4.495646, 48.384377, 58.501115, SpatialReferences.Wgs84); _distanceMeasurement = new LocationDistanceMeasurement(start, end); measureAnalysisOverlay.Analyses.Add(_distanceMeasurement); // Keep the UI updated. _distanceMeasurement.MeasurementChanged += (o, e) => { // This is needed because measurement change events occur on a non-UI thread and this code accesses UI object. RunOnUiThread(() => { // Update the label with new values in the format {value} {unit system}. _directLabel.Text = $"{_distanceMeasurement.DirectDistance.Value:F} {_distanceMeasurement.DirectDistance.Unit.Abbreviation}"; _verticalLabel.Text = $"{_distanceMeasurement.VerticalDistance.Value:F} {_distanceMeasurement.VerticalDistance.Unit.Abbreviation}"; _horizontalLabel.Text = $"{_distanceMeasurement.HorizontalDistance.Value:F} {_distanceMeasurement.HorizontalDistance.Unit.Abbreviation}"; }); }; // Update the unit spinner with the options. _unitSpinner.Adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerItem, Enum.GetNames(typeof(UnitSystem))); _unitSpinner.ItemSelected += (sender, args) => { UnitSystem[] values = (UnitSystem[])Enum.GetValues(typeof(UnitSystem)); _distanceMeasurement.UnitSystem = values[args.Position]; }; // Show the scene in the view. _mySceneView.Scene = myScene; _mySceneView.SetViewpointCamera(new Camera(start, 200, 45, 45, 0)); // Subscribe to tap events to enable updating the measurement. _mySceneView.GeoViewTapped += MySceneView_GeoViewTapped; }
private async void Initialize() { // Create the scene with basemap. _mySceneView.Scene = new Scene(BasemapStyle.ArcGISImageryStandard); // Create a surface and add the elevation service to it. Surface groundSurface = new Surface(); groundSurface.ElevationSources.Add(new ArcGISTiledElevationSource(new Uri(ElevationServiceUrl))); // Add the surface to the scene. _mySceneView.Scene.BaseSurface = groundSurface; // Get the path to the local point cloud data. string pointCloudPath = DataManager.GetDataFolder("34da965ca51d4c68aa9b3a38edb29e00", "sandiego-north-balboa-pointcloud.slpk"); // Create the point cloud layer. PointCloudLayer balboaPointCloud = new PointCloudLayer(new Uri(pointCloudPath)); // Add the point cloud to the scene. _mySceneView.Scene.OperationalLayers.Add(balboaPointCloud); // Wait for the layer to load. await balboaPointCloud.LoadAsync(); // Zoom to the extent of the point cloud. await _mySceneView.SetViewpointAsync(new Viewpoint(balboaPointCloud.FullExtent)); }
private void Initialize() { // Configure the scene with National Geographic basemap. _mySceneView.Scene = new Scene(Basemap.CreateTopographic()); // Add the base surface for elevation data. Surface elevationSurface = new Surface(); ArcGISTiledElevationSource elevationSource = new ArcGISTiledElevationSource(new Uri(_elevationServiceUrl)); elevationSurface.ElevationSources.Add(elevationSource); // Add the surface to the scene. _mySceneView.Scene.BaseSurface = elevationSurface; // Set the initial camera. MapPoint initialLocation = new MapPoint(-119.9489, 46.7592, 0, SpatialReferences.Wgs84); Camera initialCamera = new Camera(initialLocation, 15000, 40, 60, 0); _mySceneView.SetViewpointCamera(initialCamera); // Update terrain exaggeration based on the slider value. _terrainSlider.ProgressChanged += (sender, e) => { // Values are scaled to enable smoother animation - Android Seekbar has a course step size. elevationSurface.ElevationExaggeration = 1 + _terrainSlider.Progress / 20.0; }; }
private void Initialize() { // Create and add the scene. MyARSceneView.Scene = new Scene(Basemap.CreateImagery()); // Create the custom location data source and configure the AR scene view to use it. #if XAMARIN_ANDROID _locationSource = new ARLocationDataSource(Android.App.Application.Context); _locationSource.AltitudeMode = ARLocationDataSource.AltitudeAdjustmentMode.NmeaParsedMsl; #elif __IOS__ _locationSource = new ARLocationDataSource(); #endif MyARSceneView.LocationDataSource = _locationSource; // Create and add the elevation source. _elevationSource = new ArcGISTiledElevationSource(new Uri("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer")); _elevationSurface = new Surface(); _elevationSurface.ElevationSources.Add(_elevationSource); MyARSceneView.Scene.BaseSurface = _elevationSurface; // Configure the surface for AR: no navigation constraint and hidden by default. _elevationSurface.NavigationConstraint = NavigationConstraint.None; _elevationSurface.Opacity = 0; // Create a graphics overlay for the pipes. GraphicsOverlay pipesOverlay = new GraphicsOverlay(); // Use absolute surface placement to see the graphics at the correct altitude. pipesOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Absolute; // Add graphics for the pipes. pipesOverlay.Graphics.AddRange(PipeGraphics); // Display routes as red 3D tubes. SolidStrokeSymbolLayer strokeSymbolLayer = new SolidStrokeSymbolLayer(0.3, System.Drawing.Color.Red, null, StrokeSymbolLayerLineStyle3D.Tube) { CapStyle = StrokeSymbolLayerCapStyle.Round }; MultilayerPolylineSymbol tubeSymbol = new MultilayerPolylineSymbol(new[] { strokeSymbolLayer }); pipesOverlay.Renderer = new SimpleRenderer(tubeSymbol); // Configure scene view display for real-scale AR: no space effect or atmosphere effect. MyARSceneView.SpaceEffect = SpaceEffect.None; MyARSceneView.AtmosphereEffect = AtmosphereEffect.None; // Add the graphics overlay to the scene. MyARSceneView.GraphicsOverlays.Add(pipesOverlay); // Disable scene interaction. MyARSceneView.InteractionOptions = new SceneViewInteractionOptions() { IsEnabled = false }; // Enable the calibration button. CalibrateButton.IsEnabled = true; }
private void Initialize() { // Create the scene with the imagery basemap. Scene myScene = new Scene(Basemap.CreateImagery()); _mySceneView.Scene = myScene; // Add the surface elevation. Surface mySurface = new Surface(); mySurface.ElevationSources.Add(new ArcGISTiledElevationSource(_localElevationImageService)); myScene.BaseSurface = mySurface; // Add the scene layer. ArcGISSceneLayer sceneLayer = new ArcGISSceneLayer(_buildingsUrl); myScene.OperationalLayers.Add(sceneLayer); // Create the MapPoint representing the initial location. MapPoint initialLocation = new MapPoint(-4.5, 48.4, 100.0); // Create the location viewshed analysis. _viewshed = new LocationViewshed( initialLocation, _headingSlider.Progress, _pitchSlider.Progress, _horizontalAngleSlider.Progress, _verticalAngleSlider.Progress, _minimumDistanceSlider.Progress, _maximumDistanceSlider.Progress); // Create a camera based on the initial location. Camera camera = new Camera(initialLocation, 200.0, 20.0, 70.0, 0.0); // Apply the camera to the scene view. _mySceneView.SetViewpointCamera(camera); // Create an analysis overlay for showing the viewshed analysis. _analysisOverlay = new AnalysisOverlay(); // Add the viewshed analysis to the overlay. _analysisOverlay.Analyses.Add(_viewshed); // Add the analysis overlay to the SceneView. _mySceneView.AnalysisOverlays.Add(_analysisOverlay); // Update the frustum outline color. // The frustum outline shows the volume in which the viewshed analysis is performed. Viewshed.FrustumOutlineColor = System.Drawing.Color.Blue; // Subscribe to tap events to enable moving the observer. _mySceneView.GeoViewTapped += MySceneViewOnGeoViewTapped; }
private void Initialize() { Toast.MakeText(this, "Calibrate your location before collecting data!", ToastLength.Long).Show(); // Create the custom location data source and configure the AR scene view to use it. _locationDataSource = new MSLAdjustedARLocationDataSource(this); _locationDataSource.AltitudeMode = MSLAdjustedARLocationDataSource.AltitudeAdjustmentMode.NmeaParsedMsl; _arView.LocationDataSource = _locationDataSource; // Create the scene and show it. _scene = new Scene(Basemap.CreateImagery()); _arView.Scene = _scene; // Create and add the elevation surface. _elevationSource = new ArcGISTiledElevationSource(new Uri("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer")); _elevationSurface = new Surface(); _elevationSurface.ElevationSources.Add(_elevationSource); _arView.Scene.BaseSurface = _elevationSurface; // Hide the surface in AR. _elevationSurface.NavigationConstraint = NavigationConstraint.None; _elevationSurface.Opacity = 0; // Configure the space and atmosphere effects for AR. _arView.SpaceEffect = SpaceEffect.None; _arView.AtmosphereEffect = AtmosphereEffect.None; // Add a graphics overlay for displaying points in AR. _graphicsOverlay = new GraphicsOverlay(); _graphicsOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Absolute; _graphicsOverlay.Renderer = new SimpleRenderer(_tappedPointSymbol); _arView.GraphicsOverlays.Add(_graphicsOverlay); // Add the exisiting features to the scene. FeatureLayer treeLayer = new FeatureLayer(_featureTable); treeLayer.SceneProperties.SurfacePlacement = SurfacePlacement.Absolute; _arView.Scene.OperationalLayers.Add(treeLayer); // Add the event for the user tapping the screen. _arView.GeoViewTapped += arViewTapped; // Disable scene interaction. _arView.InteractionOptions = new SceneViewInteractionOptions() { IsEnabled = false }; // Enable the calibrate button. _calibrateButton.Enabled = true; }
private void Initialize() { // Configure the scene with an imagery basemap. _mySceneView.Scene = new Scene(BasemapStyle.ArcGISImageryStandard); // Add a surface to the scene for elevation. ArcGISTiledElevationSource elevationSource = new ArcGISTiledElevationSource(new Uri(_elevationServiceUrl)); Surface elevationSurface = new Surface(); elevationSurface.ElevationSources.Add(elevationSource); _mySceneView.Scene.BaseSurface = elevationSurface; // Create the graphics overlay. GraphicsOverlay overlay = new GraphicsOverlay(); // Set the surface placement mode for the overlay. overlay.SceneProperties.SurfacePlacement = SurfacePlacement.Absolute; // Create a graphic for each symbol type and add it to the scene. int index = 0; Color[] colors = { Color.Red, Color.Green, Color.Blue, Color.Purple, Color.Turquoise, Color.White }; Array symbolStyles = Enum.GetValues(typeof(SimpleMarkerSceneSymbolStyle)); foreach (SimpleMarkerSceneSymbolStyle symbolStyle in symbolStyles) { // Create the symbol. SimpleMarkerSceneSymbol symbol = new SimpleMarkerSceneSymbol(symbolStyle, colors[index], 200, 200, 200, SceneSymbolAnchorPosition.Center); // Offset each symbol so that they aren't in the same spot. double positionOffset = 0.01 * index; MapPoint point = new MapPoint(44.975 + positionOffset, 29, 500, SpatialReferences.Wgs84); // Create the graphic from the geometry and the symbol. Graphic item = new Graphic(point, symbol); // Add the graphic to the overlay. overlay.Graphics.Add(item); // Increment the index. index++; } // Show the graphics overlay in the scene. _mySceneView.GraphicsOverlays.Add(overlay); // Set the initial viewpoint. Camera initalViewpoint = new Camera(28.9672, 44.9858, 2495, 12, 53, 0); _mySceneView.SetViewpointCamera(initalViewpoint); }
private void Initialize() { // Create the custom location data source and configure the AR scene view to use it. #if XAMARIN_ANDROID _locationDataSource = new ARLocationDataSource(Android.App.Application.Context); _locationDataSource.AltitudeMode = ARLocationDataSource.AltitudeAdjustmentMode.NmeaParsedMsl; #elif __IOS__ _locationDataSource = new ARLocationDataSource(); #endif MyARSceneView.LocationDataSource = _locationDataSource; _locationDataSource.LocationChanged += LocationDataSource_LocationChanged; // Create the scene and show it. _scene = new Scene(BasemapStyle.ArcGISImageryStandard); MyARSceneView.Scene = _scene; // Create and add the elevation surface. _elevationSource = new ArcGISTiledElevationSource(new Uri( "https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer")); _elevationSurface = new Surface(); _elevationSurface.ElevationSources.Add(_elevationSource); MyARSceneView.Scene.BaseSurface = _elevationSurface; // Hide the surface in AR. _elevationSurface.NavigationConstraint = NavigationConstraint.None; _elevationSurface.Opacity = 0; // Create and add a graphics overlay for showing routes. _routeOverlay = new GraphicsOverlay(); MyARSceneView.GraphicsOverlays.Add(_routeOverlay); // Configure the graphics overlay to render graphics as yellow 3D tubes. SolidStrokeSymbolLayer strokeSymbolLayer = new SolidStrokeSymbolLayer(1, System.Drawing.Color.Yellow, null, StrokeSymbolLayerLineStyle3D.Tube); strokeSymbolLayer.CapStyle = StrokeSymbolLayerCapStyle.Round; MultilayerPolylineSymbol tubeSymbol = new MultilayerPolylineSymbol(new[] { strokeSymbolLayer }); _routeOverlay.Renderer = new SimpleRenderer(tubeSymbol); // Configure the space and atmosphere effects for AR. MyARSceneView.SpaceEffect = SpaceEffect.None; MyARSceneView.AtmosphereEffect = AtmosphereEffect.None; // Set up the route graphic. SetRoute(PassedRouteResult.Routes[0]); }
private void Initialize() { // Create a new scene Scene myScene = new Scene(); // Crate a new base map using the static/shared create imagery method Basemap myBaseMap = new Basemap(BasemapStyle.ArcGISImageryStandard); // Add the imagery basemap to the scene's base map property myScene.Basemap = myBaseMap; // Add scene (with an imagery basemap) to the scene view's scene property _mySceneView.Scene = myScene; // Create a new surface Surface mySurface = new Surface(); // Define the string that points to the elevation image service string myElevationImageService = "https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer"; // Create a Uri from the elevation image service string Uri myUri = new Uri(myElevationImageService); // Create an ArcGIS tiled elevation ArcGISTiledElevationSource myArcGISTiledElevationSource = new ArcGISTiledElevationSource { // Set the ArcGIS tiled elevation sources property to the Uri of the elevation image service Source = myUri }; // Add the ArcGIS tiled elevation source to the surface's elevated sources collection mySurface.ElevationSources.Add(myArcGISTiledElevationSource); // Set the scene's base surface to the surface with the ArcGIS tiled elevation source myScene.BaseSurface = mySurface; // Create camera with an initial camera position (Mount Everest in the Alps mountains) Camera myCamera = new Camera(28.4, 83.9, 10010.0, 10.0, 80.0, 300.0); // Set the scene view's camera position _mySceneView.SetViewpointCameraAsync(myCamera); }
private void Initialize() { // Create the scene with basemap. _mySceneView.Scene = new Scene(BasemapStyle.ArcGISImageryStandard); // Create and use an elevation surface to show terrain. Surface baseSurface = new Surface(); baseSurface.ElevationSources.Add(new ArcGISTiledElevationSource(new Uri(ElevationServiceUrl))); _mySceneView.Scene.BaseSurface = baseSurface; // Create the integrated mesh layer from URL. IntegratedMeshLayer meshLayer = new IntegratedMeshLayer(new Uri(IntegratedMeshLayerUrl)); // Add the layer to the scene's operational layers. _mySceneView.Scene.OperationalLayers.Add(meshLayer); // Start with camera pointing at the scene. _mySceneView.SetViewpointCamera(new Camera(new MapPoint(2.8259, 41.9906, 200.0), 190, 65, 0)); }
private async void Initialize() { // Create a new Scene with an imagery basemap. Scene scene = new Scene(BasemapStyle.ArcGISImageryStandard); // Add a base surface with elevation data. Surface elevationSurface = new Surface(); Uri elevationService = new Uri("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer"); elevationSurface.ElevationSources.Add(new ArcGISTiledElevationSource(elevationService)); scene.BaseSurface = elevationSurface; // Add a scene layer. Uri buildingsService = new Uri("https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/Buildings_Berlin/SceneServer"); ArcGISSceneLayer buildingsLayer = new ArcGISSceneLayer(buildingsService); scene.OperationalLayers.Add(buildingsLayer); // Assign the Scene to the SceneView. _mySceneView.Scene = scene; try { // Create a camera with an interesting view. await buildingsLayer.LoadAsync(); MapPoint center = (MapPoint)GeometryEngine.Project(buildingsLayer.FullExtent.GetCenter(), SpatialReferences.Wgs84); Camera viewCamera = new Camera(center.Y, center.X, 600, 120, 60, 0); // Set the viewpoint with the camera. _mySceneView.SetViewpointCamera(viewCamera); // Listen for taps. _mySceneView.GeoViewTapped += SceneViewTapped; } catch (Exception e) { new AlertDialog.Builder(this).SetMessage(e.ToString()).SetTitle("Error").Show(); } }
private void Initialize() { // Create the scene with a basemap. _mySceneView.Scene = new Scene(Basemap.CreateImagery()); // Add an elevation source to the scene. Surface elevationSurface = new Surface(); ArcGISTiledElevationSource elevationSource = new ArcGISTiledElevationSource(new Uri(_elevationServiceUrl)); elevationSurface.ElevationSources.Add(elevationSource); _mySceneView.Scene.BaseSurface = elevationSurface; // Set the initial viewpoint. Camera initialCamera = new Camera(64.416919, -14.483728, 100, 318, 105, 0); _mySceneView.SetViewpointCamera(initialCamera); // Apply the selected atmosphere effect option. _realisticOption.Click += (o, e) => _mySceneView.AtmosphereEffect = AtmosphereEffect.Realistic; _horizonOnlyOption.Click += (o, e) => _mySceneView.AtmosphereEffect = AtmosphereEffect.HorizonOnly; _noneOption.Click += (o, e) => _mySceneView.AtmosphereEffect = AtmosphereEffect.None; }
private void Initialize() { // Create the camera for the scene. Camera camera = new Camera(_observerPoint, 20000.0, 10.0, 70.0, 0.0); // Create a scene. Scene myScene = new Scene(Basemap.CreateImageryWithLabels()) { // Set the initial viewpoint. InitialViewpoint = new Viewpoint(_observerPoint, 1000000, camera) }; // Create the marker for showing where the user taps. _elevationMarker = SimpleMarkerSceneSymbol.CreateCylinder(Color.Red, 10, 750); // Create the text for displaying the elevation value. _elevationTextSymbol = new TextSymbol("", Color.Red, 20, Esri.ArcGISRuntime.Symbology.HorizontalAlignment.Center, Esri.ArcGISRuntime.Symbology.VerticalAlignment.Middle); _elevationTextGraphic.Symbol = _elevationTextSymbol; // Create the base surface. _baseSurface = new Surface(); _baseSurface.ElevationSources.Add(new ArcGISTiledElevationSource(_elevationUri)); // Add the base surface to the scene. myScene.BaseSurface = _baseSurface; // Graphics overlay for displaying points. _overlay = new GraphicsOverlay { SceneProperties = new LayerSceneProperties(SurfacePlacement.Absolute) }; _mySceneView.GraphicsOverlays.Add(_overlay); // Add the scene to the view. _mySceneView.Scene = myScene; }
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()); // 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 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, System.Drawing.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 ["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); 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 // The value is the duration of the timer in milliseconds. This controls the speed of the animation (fps) _animationTimer = new Timer(60) { Enabled = true, AutoReset = true }; // Move the plane every time the timer expires _animationTimer.Elapsed += AnimatePlane; // Set the initial mission for when the sample loads await ChangeMission(_missionToItemId.Keys.First()); } catch (Exception e) { new AlertDialog.Builder(this).SetMessage(e.ToString()).SetTitle("Error").Show(); } }
private async void Initialize() { try { // Create the custom location data source and configure the AR scene view to use it. #if XAMARIN_ANDROID bool locationGranted = await MainActivity.Instance.AskForLocationPermission(); if (!locationGranted) { return; } _locationDataSource = new ARLocationDataSource(Android.App.Application.Context); _locationDataSource.AltitudeMode = ARLocationDataSource.AltitudeAdjustmentMode.NmeaParsedMsl; MyARSceneView.LocationDataSource = _locationDataSource; await MyARSceneView.StartTrackingAsync(ARLocationTrackingMode.Continuous); #elif __IOS__ _locationDataSource = new ARLocationDataSource(); MyARSceneView.LocationDataSource = _locationDataSource; #endif // Create the scene and show it. _scene = new Scene(BasemapStyle.ArcGISImageryStandard); MyARSceneView.Scene = _scene; // Create and add the elevation surface. _elevationSource = new ArcGISTiledElevationSource(new Uri("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer")); _elevationSurface = new Surface(); _elevationSurface.ElevationSources.Add(_elevationSource); MyARSceneView.Scene.BaseSurface = _elevationSurface; // Hide the surface in AR. _elevationSurface.NavigationConstraint = NavigationConstraint.None; _elevationSurface.Opacity = 0; // Configure the space and atmosphere effects for AR. MyARSceneView.SpaceEffect = SpaceEffect.None; MyARSceneView.AtmosphereEffect = AtmosphereEffect.None; // Add a graphics overlay for displaying points in AR. _graphicsOverlay = new GraphicsOverlay(); _graphicsOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Absolute; _graphicsOverlay.Renderer = new SimpleRenderer(_tappedPointSymbol); MyARSceneView.GraphicsOverlays.Add(_graphicsOverlay); // Add the exisiting features to the scene. FeatureLayer treeLayer = new FeatureLayer(_featureTable); treeLayer.SceneProperties.SurfacePlacement = SurfacePlacement.Absolute; MyARSceneView.Scene.OperationalLayers.Add(treeLayer); // Add the event for the user tapping the screen. MyARSceneView.GeoViewTapped += ARViewTapped; // Disable scene interaction. MyARSceneView.InteractionOptions = new SceneViewInteractionOptions() { IsEnabled = false }; // Enable the calibrate button. CalibrateButton.IsEnabled = true; } catch (Exception ex) { Console.WriteLine(ex.Message); await Application.Current.MainPage.DisplayAlert("Error", "Could not create feature", "OK"); } }
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); CreateErrorDialog("Loading plane model failed. Sample failed to initialize."); 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; }
private async Task Initialize() { // Create the scene with an imagery basemap. _mySceneView.Scene = new Scene(BasemapStyle.ArcGISImageryStandard); // 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); // 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. 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; }; } catch (Exception e) { new AlertDialog.Builder(this).SetMessage(e.ToString()).SetTitle("Error").Show(); } }