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, 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); 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) { MessageBox.Show(e.ToString(), "Error"); } }
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); // Configure graphics overlay for the tank and add the overlay to the SceneView. _tankOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Relative; MySceneView.GraphicsOverlays.Add(_tankOverlay); // Configure heading expression for 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. DispatcherTimer animationTimer = new DispatcherTimer() { Interval = new TimeSpan(0, 0, 0, 0, 60) }; // - Move the tank every time the timer expires. animationTimer.Tick += (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) { await new MessageDialog(e.ToString(), "Error").ShowAsync(); } }
private async void Initialize() { // Create scene. Scene myScene = new Scene(Basemap.CreateImageryWithLabels()) { InitialViewpoint = new Viewpoint(_observerPoint, 1600) }; // Create the elevation source. ElevationSource myElevationSource = new ArcGISTiledElevationSource(_elevationUri); // Add the elevation source to the scene. myScene.BaseSurface.ElevationSources.Add(myElevationSource); // Create the building scene layer. ArcGISSceneLayer mySceneLayer = new ArcGISSceneLayer(_buildingsUri); // Add the building layer to the scene. myScene.OperationalLayers.Add(mySceneLayer); // Add the observer to the scene. // Create a graphics overlay with relative surface placement; relative surface placement allows the Z position of the observation point to be adjusted. GraphicsOverlay overlay = new GraphicsOverlay() { SceneProperties = new LayerSceneProperties(SurfacePlacement.Relative) }; // Create the symbol that will symbolize the observation point. SimpleMarkerSceneSymbol symbol = new SimpleMarkerSceneSymbol(SimpleMarkerSceneSymbolStyle.Sphere, Color.Red, 10, 10, 10, SceneSymbolAnchorPosition.Bottom); // Create the observation point graphic from the point and symbol. _observerGraphic = new Graphic(_observerPoint, symbol); // Add the observer to the overlay. overlay.Graphics.Add(_observerGraphic); // Add the overlay to the scene. MySceneView.GraphicsOverlays.Add(overlay); try { // Add the taxi to the scene. // Create the model symbol for the taxi. ModelSceneSymbol taxiSymbol = await ModelSceneSymbol.CreateAsync(new Uri(DataManager.GetDataFolder("3af5cfec0fd24dac8d88aea679027cb9", "dolmus.3ds"))); // Set the anchor position for the mode; ensures that the model appears above the ground. taxiSymbol.AnchorPosition = SceneSymbolAnchorPosition.Bottom; // Create the graphic from the taxi starting point and the symbol. _taxiGraphic = new Graphic(_points[0], taxiSymbol); // Add the taxi graphic to the overlay. overlay.Graphics.Add(_taxiGraphic); // Create GeoElement Line of sight analysis (taxi to building). // Create the analysis. _geoLine = new GeoElementLineOfSight(_observerGraphic, _taxiGraphic) { // Apply an offset to the target. This helps avoid some false negatives. TargetOffsetZ = 2 }; // Create the analysis overlay. AnalysisOverlay myAnalysisOverlay = new AnalysisOverlay(); // Add the analysis to the overlay. myAnalysisOverlay.Analyses.Add(_geoLine); // Add the analysis overlay to the scene. MySceneView.AnalysisOverlays.Add(myAnalysisOverlay); // Create a timer; this will enable animating the taxi. DispatcherTimer animationTimer = new DispatcherTimer() { Interval = new TimeSpan(0, 0, 0, 0, 60) }; // Move the taxi every time the timer expires. animationTimer.Tick += AnimationTimer_Tick; // Start the timer. animationTimer.Start(); // Subscribe to TargetVisible events; allows for updating the UI and selecting the taxi when it is visible. _geoLine.TargetVisibilityChanged += Geoline_TargetVisibilityChanged; // Add the scene to the view. MySceneView.Scene = myScene; } catch (Exception e) { await new MessageDialog2(e.ToString(), "Error").ShowAsync(); } }
private async void Initialize() { // Create scene. Scene myScene = new Scene(Basemap.CreateImageryWithLabels()) { // Set initial viewpoint. InitialViewpoint = new Viewpoint(_observerPoint, 1600) }; // Create the elevation source. ElevationSource myElevationSource = new ArcGISTiledElevationSource(_elevationUri); // Add the elevation source to the scene. myScene.BaseSurface.ElevationSources.Add(myElevationSource); // Create the building scene layer. ArcGISSceneLayer mySceneLayer = new ArcGISSceneLayer(_buildingsUri); // Add the building layer to the scene. myScene.OperationalLayers.Add(mySceneLayer); // Add the observer to the scene. // Create a graphics overlay with relative surface placement; relative surface placement allows the Z position of the observation point to be adjusted. GraphicsOverlay overlay = new GraphicsOverlay { SceneProperties = new LayerSceneProperties(SurfacePlacement.Relative) }; // Create the symbol that will symbolize the observation point. SimpleMarkerSceneSymbol symbol = new SimpleMarkerSceneSymbol(SimpleMarkerSceneSymbolStyle.Sphere, System.Drawing.Color.Red, 10, 10, 10, SceneSymbolAnchorPosition.Bottom); // Create the observation point graphic from the point and symbol. _observerGraphic = new Graphic(_observerPoint, symbol); // Add the observer to the overlay. overlay.Graphics.Add(_observerGraphic); // Add the overlay to the scene. _mySceneView.GraphicsOverlays.Add(overlay); try { // Add the taxi to the scene. // Get the path to the model. string taxiModelPath = DataManager.GetDataFolder("3af5cfec0fd24dac8d88aea679027cb9", "dolmus.3ds"); // Create the model symbol for the taxi. ModelSceneSymbol taxiSymbol = await ModelSceneSymbol.CreateAsync(new Uri(taxiModelPath)); // Set the anchor position for the mode; ensures that the model appears above the ground. taxiSymbol.AnchorPosition = SceneSymbolAnchorPosition.Bottom; // Create the graphic from the taxi starting point and the symbol. _taxiGraphic = new Graphic(_points[0], taxiSymbol); // Add the taxi graphic to the overlay. overlay.Graphics.Add(_taxiGraphic); // Create GeoElement Line of sight analysis (taxi to building). // Create the analysis. _geoLine = new GeoElementLineOfSight(_observerGraphic, _taxiGraphic) { // Apply an offset to the target. This helps avoid some false negatives. TargetOffsetZ = 2 }; // Create the analysis overlay. AnalysisOverlay myAnalysisOverlay = new AnalysisOverlay(); // Add the analysis to the overlay. myAnalysisOverlay.Analyses.Add(_geoLine); // Add the analysis overlay to the scene. _mySceneView.AnalysisOverlays.Add(myAnalysisOverlay); // Create a timer; this will enable animating the taxi. _animationTimer = new Timer(120); // Keep the timer running continuously. _animationTimer.AutoReset = true; // Add the scene to the view. _mySceneView.Scene = myScene; } catch (Exception e) { new UIAlertView("Error", e.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show(); } }
private void Initialize() { // Create new scene with imagery basemap. Scene scene = new Scene(Basemap.CreateImagery()); // Create a camera with coordinates showing layer data. Camera camera = new Camera(53.04, -4.04, 1300, 0, 90.0, 0); // Assign the Scene to the SceneView. _mySceneView.Scene = scene; // Create ElevationSource from elevation data Uri. ArcGISTiledElevationSource elevationSource = new ArcGISTiledElevationSource( new Uri("http://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer")); // Add elevationSource to BaseSurface's ElevationSources. _mySceneView.Scene.BaseSurface.ElevationSources.Add(elevationSource); // Set view point of scene view using camera. _mySceneView.SetViewpointCameraAsync(camera); // Create overlays with elevation modes. GraphicsOverlay drapedOverlay = new GraphicsOverlay { SceneProperties = { SurfacePlacement = SurfacePlacement.Draped } }; _mySceneView.GraphicsOverlays.Add(drapedOverlay); GraphicsOverlay relativeOverlay = new GraphicsOverlay { SceneProperties = { SurfacePlacement = SurfacePlacement.Relative } }; _mySceneView.GraphicsOverlays.Add(relativeOverlay); GraphicsOverlay absoluteOverlay = new GraphicsOverlay { SceneProperties = { SurfacePlacement = SurfacePlacement.Absolute } }; _mySceneView.GraphicsOverlays.Add(absoluteOverlay); // Create point for graphic location. MapPoint point = new MapPoint(-4.04, 53.06, 1000, camera.Location.SpatialReference); // Create a red circle symbol. SimpleMarkerSymbol circleSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Color.Red, 10); // Create a text symbol for each elevation mode TextSymbol drapedText = new TextSymbol("DRAPED", Color.FromArgb(255, 255, 255, 255), 10, HorizontalAlignment.Center, VerticalAlignment.Middle); drapedText.OffsetY += 20; TextSymbol relativeText = new TextSymbol("RELATIVE", Color.FromArgb(255, 255, 255, 255), 10, HorizontalAlignment.Center, VerticalAlignment.Middle); relativeText.OffsetY += 20; TextSymbol absoluteText = new TextSymbol("ABSOLUTE", Color.FromArgb(255, 255, 255, 255), 10, HorizontalAlignment.Center, VerticalAlignment.Middle); absoluteText.OffsetY += 20; // Add the point graphic and text graphic to the corresponding graphics overlay. drapedOverlay.Graphics.Add(new Graphic(point, circleSymbol)); drapedOverlay.Graphics.Add(new Graphic(point, drapedText)); relativeOverlay.Graphics.Add(new Graphic(point, circleSymbol)); relativeOverlay.Graphics.Add(new Graphic(point, relativeText)); absoluteOverlay.Graphics.Add(new Graphic(point, circleSymbol)); absoluteOverlay.Graphics.Add(new Graphic(point, absoluteText)); }
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); _mySceneView.Scene.BaseSurface = new Surface { ElevationSources = { tiledElevationSource } }; // 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. _tankOverlay.Renderer = new SimpleRenderer { SceneProperties = { HeadingExpression = "[HEADING]" } }; // Create the tank graphic - get the model path. string modelPath = DataManager.GetDataFolder("07d62a792ab6496d9b772a24efea45d0", "bradle.3ds"); // - 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 and use a camera controller to orbit the tank. _mySceneView.CameraController = new OrbitGeoElementCameraController(_tank, 200.0) { CameraPitchOffset = 45.0 }; // 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() { _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. await ChangeMission(_missionToItemId.Keys.First()); } catch (Exception e) { new UIAlertView("Error", e.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show(); } }
public async void InitScene(string json, SceneView sceneView) { try { JsonReader jreader = new JsonTextReader(new System.IO.StringReader(json)); JObject jo = (JObject)JsonConvert.DeserializeObject(json); // ¼ÓÔØoperationalLayers ͼ²ã if (jo["operationalLayers"].Count() > 0) { int LayerCount = 1; layers.Clear(); for (int j = 0; j < jo["operationalLayers"].Count(); j++, LayerCount++) { string operational_title = jo["operationalLayers"][j]["title"].ToString(); string operational_layerType = jo["operationalLayers"][j]["layerType"].ToString(); if (operational_layerType.Equals("GroupLayer")) { if (jo["operationalLayers"][j]["layers"] != null && jo["operationalLayers"][j]["layers"].Count() > 0) { for (int i = 0; i < jo["operationalLayers"][j]["layers"].Count(); i++) { string GrouplLayers_title = jo["operationalLayers"][j]["layers"][i]["title"].ToString(); string GrouplLayers_url = jo["operationalLayers"][j]["layers"][i]["url"].ToString(); ArcGISSceneLayer Scenelayer = new ArcGISSceneLayer(new Uri(GrouplLayers_url)); string Content = $"ͼ²ã{LayerCount} £º {GrouplLayers_title}"; sceneView.Scene.OperationalLayers.Add(Scenelayer); layers.Add(new ItemLayer(Content)); //Label lab = new Label { Content = $"ͼ²ã{LayerCount} £º {GrouplLayers_title}" }; } } } else { string operational_url = jo["operationalLayers"][j]["url"].ToString(); ArcGISSceneLayer Scenelayer = new ArcGISSceneLayer(new Uri(operational_url)); sceneView.Scene.OperationalLayers.Add(Scenelayer); string Content = $"ͼ²ã{LayerCount} £º {operational_title}"; layers.Add(new ItemLayer(Content)); //Label lab = new Label { Content = $"ͼ²ã{LayerCount} £º {operational_title}" }; } } if (layers.Count > 0) { Context context = this.BaseContext; ListLayerAdapter adapter = new ListLayerAdapter(layers, context); listLayer.Adapter = adapter; } } if (jo["baseMap"]["baseMapLayers"] != null && jo["baseMap"]["baseMapLayers"].Count() > 0) { // ¼ÓÔص×ͼ baseMap string baseMapLayers_layerType = jo["baseMap"]["baseMapLayers"][0]["layerType"].ToString(); if (baseMapLayers_layerType.Equals("ArcGISTiledMapServiceLayer")) { string baseMapLayers_url = jo["baseMap"]["baseMapLayers"][0]["url"].ToString(); ArcGISMapImageLayer basemap = new ArcGISMapImageLayer(new Uri(baseMapLayers_url)); Basemap map = new Basemap(basemap); sceneView.Scene.Basemap = map; } } // ¼ÓÔØ¸ß³Ì elevationLayers if (jo["baseMap"]["elevationLayers"] != null && jo["baseMap"]["elevationLayers"].Count() > 0) { for (int j = 0; j < jo["baseMap"]["elevationLayers"].Count(); j++) { string elevationLayer_url = jo["baseMap"]["elevationLayers"][j]["url"].ToString(); string elevationLayer_layerType = jo["baseMap"]["elevationLayers"][j]["layerType"].ToString(); var elevationSource = new ArcGISTiledElevationSource(new System.Uri(elevationLayer_url)); sceneView.Scene.BaseSurface.ElevationSources.Add(elevationSource); } } // ¼ÓÔØÊéÇ© slides if (jo["presentation"]["slides"] != null && jo["presentation"]["slides"].Count() >= 0) { int bookMarkCount = 1; bks.Clear(); for (int j = 0; j < jo["presentation"]["slides"].Count(); j++, bookMarkCount++) { string sttt = JsonConvert.SerializeObject(jo["presentation"]["slides"][j]["viewpoint"]); string bkname = jo["presentation"]["slides"][j]["title"]["text"].ToString(); string bkimage = jo["presentation"]["slides"][j]["thumbnail"]["url"].ToString(); double targetGeometry_x = (double)jo["presentation"]["slides"][j]["viewpoint"]["targetGeometry"] ["x"]; double targetGeometry_y = (double)jo["presentation"]["slides"][j]["viewpoint"]["targetGeometry"] ["y"]; double targetGeometry_z = (double)jo["presentation"]["slides"][j]["viewpoint"]["targetGeometry"] ["z"]; double slidesx = (double)jo["presentation"]["slides"][j]["viewpoint"]["camera"]["position"]["x"]; double slidesy = (double)jo["presentation"]["slides"][j]["viewpoint"]["camera"]["position"]["y"]; double slidesz = (double)jo["presentation"]["slides"][j]["viewpoint"]["camera"]["position"]["z"]; double slides_heading = (double)jo["presentation"]["slides"][j]["viewpoint"]["camera"]["heading"]; double slides_tilt = (double)jo["presentation"]["slides"][j]["viewpoint"]["camera"]["tilt"]; int SRID = (int)jo["presentation"]["slides"][j]["viewpoint"]["camera"]["position"]["spatialReference"]["latestWkid"]; MapPoint cmpt = new MapPoint(slidesx, slidesy, slidesz, SpatialReference.Create(SRID)); Camera camera = new Camera(cmpt, slides_heading, slides_tilt, 0); MapPoint mp = new MapPoint(targetGeometry_x, targetGeometry_y, targetGeometry_z, SpatialReference.Create(SRID)); Viewpoint vp = new Viewpoint(mp, camera); Bookmark bk = new Bookmark(bkname, vp); sceneView.Scene.Bookmarks.Add(bk); ItemBookMark itembk = new ItemBookMark(bkname, bkimage, bk); bks.Add(itembk); } if (bks.Count > 0) { Context context = this.BaseContext; ListBookAdapter adapter = new ListBookAdapter(bks, context); listBookMark.Adapter = adapter; } } double initCamera_x = (double)jo["initialState"]["viewpoint"]["camera"]["position"]["x"]; double initCamera_y = (double)jo["initialState"]["viewpoint"]["camera"]["position"]["y"]; double initCamera_z = (double)jo["initialState"]["viewpoint"]["camera"]["position"]["z"]; double initCamera_heading = (double)jo["initialState"]["viewpoint"]["camera"]["heading"]; double initCamera_tilt = (double)jo["initialState"]["viewpoint"]["camera"]["tilt"]; int initSRID = (int)jo["initialState"]["viewpoint"]["camera"]["position"]["spatialReference"]["latestWkid"]; MapPoint initcmpt = new MapPoint(initCamera_x, initCamera_y, initCamera_z, SpatialReference.Create(initSRID)); Camera initCamera = new Camera(initcmpt, initCamera_heading, initCamera_tilt, 0); await _sceneLeftView.SetViewpointCameraAsync(initCamera, TimeSpan.FromSeconds(10)); } catch (Exception ex) { } }
private async void Initialize() { // Create scene Scene myScene = new Scene(Basemap.CreateImageryWithLabels()) { // Set initial viewpoint InitialViewpoint = new Viewpoint(_observerPoint, 1600) }; // Create the elevation source ElevationSource myElevationSource = new ArcGISTiledElevationSource(_elevationUri); // Add the elevation source to the scene myScene.BaseSurface.ElevationSources.Add(myElevationSource); // Create the building scene layer ArcGISSceneLayer mySceneLayer = new ArcGISSceneLayer(_buildingsUri); // Add the building layer to the scene myScene.OperationalLayers.Add(mySceneLayer); // Add the observer to the scene // Create a graphics overlay with relative surface placement; relative surface placement allows the Z position of the observation point to be adjusted GraphicsOverlay overlay = new GraphicsOverlay() { SceneProperties = new LayerSceneProperties(SurfacePlacement.Relative) }; // Create the symbol that will symbolize the observation point SimpleMarkerSceneSymbol symbol = new SimpleMarkerSceneSymbol(SimpleMarkerSceneSymbolStyle.Sphere, Colors.Red, 10, 10, 10, SceneSymbolAnchorPosition.Bottom); // Create the observation point graphic from the point and symbol _observerGraphic = new Graphic(_observerPoint, symbol); // Add the observer to the overlay overlay.Graphics.Add(_observerGraphic); // Add the overlay to the scene MySceneView.GraphicsOverlays.Add(overlay); try { // Add the taxi to the scene // Create the model symbol for the taxi ModelSceneSymbol taxiSymbol = await ModelSceneSymbol.CreateAsync(new Uri(GetModelUri())); // Set the anchor position for the mode; ensures that the model appears above the ground taxiSymbol.AnchorPosition = SceneSymbolAnchorPosition.Bottom; // Create the graphic from the taxi starting point and the symbol _taxiGraphic = new Graphic(_points[0], taxiSymbol); // Add the taxi graphic to the overlay overlay.Graphics.Add(_taxiGraphic); // Create GeoElement Line of sight analysis (taxi to building) // Create the analysis _geoLine = new GeoElementLineOfSight(_observerGraphic, _taxiGraphic) { // Apply an offset to the target. This helps avoid some false negatives TargetOffsetZ = 2 }; // Create the analysis overlay AnalysisOverlay myAnalysisOverlay = new AnalysisOverlay(); // Add the analysis to the overlay myAnalysisOverlay.Analyses.Add(_geoLine); // Add the analysis overlay to the scene MySceneView.AnalysisOverlays.Add(myAnalysisOverlay); // Create a timer; this will enable animating the taxi Device.StartTimer(new TimeSpan(0, 0, 0, 0, 60), () => { // Move the taxi every time the timer elapses AnimationTimer_Elapsed(this, null); // Keep the timer running return(true); }); // Subscribe to TargetVisible events; allows for updating the UI and selecting the taxi when it is visible _geoLine.TargetVisibilityChanged += Geoline_TargetVisibilityChanged; // Add the scene to the view MySceneView.Scene = myScene; } catch (Exception e) { await Application.Current.MainPage.DisplayAlert("Error", e.ToString(), "OK"); } }
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() { LoadData(); //=====================放球站============= // Create overlay to where graphics are shown GraphicsOverlay overlay = new GraphicsOverlay(); MyMapView.GraphicsOverlays.Add(overlay); try { await CreatePictureMarkerSymbolFromResources(overlay); } catch (Exception e) { MessageBox.Show(e.ToString(), "Error"); } //================== 二维场景探空仪展示 ============== //加载图片 int count = Global.DectorNamelist.Count; if (count > 0) { for (int i = 0; i < count; i++) { Assembly currentAssembly = Assembly.GetExecutingAssembly(); // Get image as a stream from the resources // Picture is defined as EmbeddedResource and DoNotCopy Stream resourceStream = currentAssembly.GetManifestResourceStream( this.GetType(), "qiqiu.png"); // Create new symbol using asynchronous factory method from stream PictureMarkerSymbol pinSymbol = await PictureMarkerSymbol.CreateAsync(resourceStream); pinSymbol.Width = 35; pinSymbol.Height = 35; //位置 int index = 0; double positionOffset = 0.01 * index; MapPoint point = new MapPoint(111, 30, 0, SpatialReferences.Wgs84); // Create the graphic from the geometry and the symbol. Graphic _plane2D; _plane2D = new Graphic(point, pinSymbol); // Add the graphic to the overlay. overlay.Graphics.Add(_plane2D); Dector2D.Add(_plane2D); } } //==========================场景基础地图=========== // Create a new Scene with an imagery basemap Scene myScene = new Scene(Basemap.CreateImagery()); // Create a scene layer to show buildings in the Scene ArcGISSceneLayer buildingsLayer = new ArcGISSceneLayer(new Uri(_buildingsServiceUrl)); myScene.OperationalLayers.Add(buildingsLayer); // Create an elevation(海拔) source for the Scene ArcGISTiledElevationSource elevationSrc = new ArcGISTiledElevationSource(new Uri(_elevationSourceUrl)); myScene.BaseSurface.ElevationSources.Add(elevationSrc); ElevationSource elevationSource = new ArcGISTiledElevationSource(_elevationServiceUrl); myScene.BaseSurface.ElevationSources.Add(elevationSource); // Add the Scene to the SceneView MySceneView.Scene = myScene; //======================三维探空仪==================== // Create the graphics overlay. GraphicsOverlay overlay1 = new GraphicsOverlay(); //=====放球站====== try { await CreatePictureMarkerSymbolFromResources(overlay1); } catch (Exception e) { MessageBox.Show(e.ToString(), "Error"); } MySceneView.GraphicsOverlays.Add(overlay1); if (Global.DectorNamelist.Count > 0) { for (int i = 0; i < Global.DectorNamelist.Count; i++) { GraphicsOverlay dectoroverlay = new GraphicsOverlay(); // Set the surface placement mode for the overlay. dectoroverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Absolute; MapPoint point = new MapPoint(111, 30, 0, SpatialReferences.Wgs84); SimpleMarkerSymbol circleSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Color.Blue, 20); Graphic _plane3D; // Create the graphic from the geometry and the symbol. _plane3D = new Graphic(point, circleSymbol); // Add the graphic to the overlay. dectoroverlay.Graphics.Add(_plane3D); // Show the graphics overlay in the scene. MySceneView.GraphicsOverlays.Add(dectoroverlay); Dector3D.Add(_plane3D); /* * * _orbitCameraController = new OrbitGeoElementCameraController(_plane3D, 30.0) * { * CameraPitchOffset = 75.0 * }; * MySceneView.CameraController = _orbitCameraController; */ } } //===========跟随相机控制======== //================加载探空仪位置信息=========== //==================动态更新=============== _animationTimer = new Timer(2000) { Enabled = true, AutoReset = true }; //动态更新探空仪位置 _animationTimer.Elapsed += AnimatePlane; //====二维预测轨迹===== //SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, Color.FromArgb(0xFF, 0x80, 0x00, 0x80), 4); // _overlay.Renderer = new SimpleRenderer(lineSymbol); // MyMapView.GraphicsOverlays.Add(_overlay); //==========三维预测轨迹========= // SimpleLineSymbol lineSymbol1 = new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, Color.FromArgb(0xFF, 0x80, 0x00, 0x80), 4); // _overlay1.Renderer = new SimpleRenderer(lineSymbol1); // // Set the surface placement mode for the overlay. for (int i = 0; i < Global.DectorNamelist.Count; i++) { GraphicsOverlay _overlay1 = new GraphicsOverlay(); GraphicsOverlay _overlay = new GraphicsOverlay(); _overlay1.SceneProperties.SurfacePlacement = SurfacePlacement.Absolute; //MySceneView.GraphicsOverlays.Add(_overlay1); MySceneView.GraphicsOverlays.Add(_overlay1); MyMapView.GraphicsOverlays.Add(_overlay); Dector3Doverlay.Add(_overlay1); Dector2Doverlay.Add(_overlay); } //===================三维地图初始视点================ heading = 344.488; // Set the viewpoint with a new camera focused on the castle in Brest observerCamera = new Camera(new MapPoint(112, 29, 2495, SpatialReferences.Wgs84), heading, 74.1212, 0.0); await MySceneView.SetViewpointCameraAsync(observerCamera); //====================通过鼠标点击改变三维地图视点================== MyMapView.GeoViewTapped += Map_Tapped; if (Global.namelist.Count > 0) { string[] strArr = new string[3]; string sArguments = @"station.py"; //调用的python的文件名字 strArr[0] = Global.lonlist[0].ToString(); strArr[1] = Global.latlist[0].ToString(); strArr[2] = Global.radiuslist[0].ToString(); RunPythonScript(sArguments, "-u", strArr); } }
private void Initialize() { // Create new Scene Scene myScene = new Scene(); // Set Scene's base map property myScene.Basemap = Basemap.CreateImagery(); // Create a camera with coordinates showing layer data Camera camera = new Camera(53.04, -4.04, 1300, 0, 90.0, 0); // Assign the Scene to the SceneView MySceneView.Scene = myScene; // Create ElevationSource from elevation data Uri ArcGISTiledElevationSource elevationSource = new ArcGISTiledElevationSource( new Uri("http://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer")); // Add elevationSource to BaseSurface's ElevationSources MySceneView.Scene.BaseSurface.ElevationSources.Add(elevationSource); // Set view point of scene view using camera MySceneView.SetViewpointCameraAsync(camera); // Create overlays with elevation modes GraphicsOverlay drapedOverlay = new GraphicsOverlay(); drapedOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Draped; MySceneView.GraphicsOverlays.Add(drapedOverlay); GraphicsOverlay relativeOverlay = new GraphicsOverlay(); relativeOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Relative; MySceneView.GraphicsOverlays.Add(relativeOverlay); GraphicsOverlay absoluteOverlay = new GraphicsOverlay(); absoluteOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Absolute; MySceneView.GraphicsOverlays.Add(absoluteOverlay); // Create point for graphic location MapPoint point = new MapPoint(-4.04, 53.06, 1000, camera.Location.SpatialReference); // Create a red circle symbol SimpleMarkerSymbol circleSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Colors.Red, 10); // Create a text symbol for each elevation mode TextSymbol drapedText = new TextSymbol("DRAPED", Colors.White, 10, Esri.ArcGISRuntime.Symbology.HorizontalAlignment.Left, Esri.ArcGISRuntime.Symbology.VerticalAlignment.Middle); TextSymbol relativeText = new TextSymbol("RELATIVE", Colors.White, 10, Esri.ArcGISRuntime.Symbology.HorizontalAlignment.Left, Esri.ArcGISRuntime.Symbology.VerticalAlignment.Middle); TextSymbol absoluteText = new TextSymbol("ABSOLUTE", Colors.White, 10, Esri.ArcGISRuntime.Symbology.HorizontalAlignment.Left, Esri.ArcGISRuntime.Symbology.VerticalAlignment.Middle); // Add the point graphic and text graphic to the corresponding graphics overlay drapedOverlay.Graphics.Add(new Graphic(point, circleSymbol)); drapedOverlay.Graphics.Add(new Graphic(point, drapedText)); relativeOverlay.Graphics.Add(new Graphic(point, circleSymbol)); relativeOverlay.Graphics.Add(new Graphic(point, relativeText)); absoluteOverlay.Graphics.Add(new Graphic(point, circleSymbol)); absoluteOverlay.Graphics.Add(new Graphic(point, absoluteText)); }
private async void Initialize() { // Create and add the map. MyMapView.Map = new Map(Basemap.CreateImagery()); MyMapView.PropertyChanged += async(o, e) => { if (e.PropertyName == nameof(MyMapView.LocationDisplay) && MyMapView.LocationDisplay != null) { // Start the location display on the mapview. try { // Permission request only needed on Android. #if XAMARIN_ANDROID // See implementation in MainActivity.cs in the Android platform project. bool permissionGranted = await MainActivity.Instance.AskForLocationPermission(); if (!permissionGranted) { throw new Exception("Location permission not granted."); } #endif MyMapView.LocationDisplay.AutoPanMode = LocationDisplayAutoPanMode.Recenter; await MyMapView.LocationDisplay.DataSource.StartAsync(); MyMapView.LocationDisplay.IsEnabled = true; } catch (Exception ex) { Debug.WriteLine(ex); await Application.Current.MainPage.DisplayAlert("Couldn't start location", ex.Message, "OK"); } } }; // Add a graphics overlay for the drawn pipes. MyMapView.GraphicsOverlays.Add(_pipesOverlay); _pipesOverlay.Renderer = new SimpleRenderer(new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, System.Drawing.Color.Red, 2)); // Set the SketchEditor for the map. MyMapView.SketchEditor = _sketchEditor; try { // Create an elevation source and Surface. _elevationSource = new ArcGISTiledElevationSource(new Uri("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer")); await _elevationSource.LoadAsync(); _elevationSurface = new Surface(); _elevationSurface.ElevationSources.Add(_elevationSource); await _elevationSurface.LoadAsync(); } catch (Exception ex) { Debug.WriteLine(ex.Message); await Application.Current.MainPage.DisplayAlert("Error", "Failed to load elevation.", "OK"); } // Enable the add button. AddButton.IsEnabled = true; }
private void Initialize() { // Create new Scene Scene myScene = new Scene { // Set Scene's base map property Basemap = Basemap.CreateImagery() }; // Create a camera with coordinates showing layer data Camera camera = new Camera(53.04, -4.04, 1300, 0, 90.0, 0); // Assign the Scene to the SceneView MySceneView.Scene = myScene; // Create ElevationSource from elevation data Uri ArcGISTiledElevationSource elevationSource = new ArcGISTiledElevationSource( new Uri("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer")); // Add elevationSource to BaseSurface's ElevationSources MySceneView.Scene.BaseSurface.ElevationSources.Add(elevationSource); // Set view point of scene view using camera MySceneView.SetViewpointCameraAsync(camera); // Create overlays with elevation modes _drapedBillboardedOverlay = new GraphicsOverlay(); _drapedBillboardedOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.DrapedBillboarded; MySceneView.GraphicsOverlays.Add(_drapedBillboardedOverlay); _drapedFlatOverlay = new GraphicsOverlay(); _drapedFlatOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.DrapedFlat; GraphicsOverlay relativeOverlay = new GraphicsOverlay(); relativeOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Relative; MySceneView.GraphicsOverlays.Add(relativeOverlay); GraphicsOverlay absoluteOverlay = new GraphicsOverlay(); absoluteOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Absolute; MySceneView.GraphicsOverlays.Add(absoluteOverlay); // Create point for graphic location MapPoint point = new MapPoint(-4.04, 53.06, 1000, camera.Location.SpatialReference); // Create a red triangle symbol SimpleMarkerSymbol triangleSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Triangle, Color.FromArgb(255, 255, 0, 0), 10); // Create a text symbol for each elevation mode TextSymbol drapedBillboardedText = new TextSymbol("DRAPED BILLBOARDED", Color.FromArgb(255, 255, 255, 255), 10, Esri.ArcGISRuntime.Symbology.HorizontalAlignment.Center, Esri.ArcGISRuntime.Symbology.VerticalAlignment.Middle); drapedBillboardedText.OffsetY += 20; TextSymbol drapedFlatText = new TextSymbol("DRAPED FLAT", Color.FromArgb(255, 255, 255, 255), 10, Esri.ArcGISRuntime.Symbology.HorizontalAlignment.Center, Esri.ArcGISRuntime.Symbology.VerticalAlignment.Middle); drapedFlatText.OffsetY += 20; TextSymbol relativeText = new TextSymbol("RELATIVE", Color.FromArgb(255, 255, 255, 255), 10, Esri.ArcGISRuntime.Symbology.HorizontalAlignment.Center, Esri.ArcGISRuntime.Symbology.VerticalAlignment.Middle); relativeText.OffsetY += 20; TextSymbol absoluteText = new TextSymbol("ABSOLUTE", Color.FromArgb(255, 255, 255, 255), 10, Esri.ArcGISRuntime.Symbology.HorizontalAlignment.Center, Esri.ArcGISRuntime.Symbology.VerticalAlignment.Middle); absoluteText.OffsetY += 20; // Add the point graphic and text graphic to the corresponding graphics overlay _drapedBillboardedOverlay.Graphics.Add(new Graphic(point, triangleSymbol)); _drapedBillboardedOverlay.Graphics.Add(new Graphic(point, drapedBillboardedText)); _drapedFlatOverlay.Graphics.Add(new Graphic(point, triangleSymbol)); _drapedFlatOverlay.Graphics.Add(new Graphic(point, drapedFlatText)); relativeOverlay.Graphics.Add(new Graphic(point, triangleSymbol)); relativeOverlay.Graphics.Add(new Graphic(point, relativeText)); absoluteOverlay.Graphics.Add(new Graphic(point, triangleSymbol)); absoluteOverlay.Graphics.Add(new Graphic(point, absoluteText)); BillboardButton.Checked += BillboardedClick; FlatButton.Checked += FlatClick; }
private void Initialize() { // Create new Scene. Scene myScene = new Scene { // Set the Scene's basemap property. Basemap = Basemap.CreateImagery() }; // Create a camera with coordinates showing layer data. Camera camera = new Camera(48.389124348393182, -4.4595173327138591, 140, 322, 74, 0); // Assign the Scene to the SceneView. MySceneView.Scene = myScene; // Create ElevationSource from elevation data Uri. ArcGISTiledElevationSource elevationSource = new ArcGISTiledElevationSource( new Uri("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer")); // Create scene layer from the Brest, France scene server. var sceneLayer = new ArcGISSceneLayer(new Uri("https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/Buildings_Brest/SceneServer")); MySceneView.Scene.OperationalLayers.Add(sceneLayer); // Add elevationSource to BaseSurface's ElevationSources. MySceneView.Scene.BaseSurface.ElevationSources.Add(elevationSource); // Set view point of scene view using camera. MySceneView.SetViewpointCameraAsync(camera); // Create overlays with elevation modes. _drapedBillboardedOverlay = new GraphicsOverlay(); _drapedBillboardedOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.DrapedBillboarded; MySceneView.GraphicsOverlays.Add(_drapedBillboardedOverlay); _drapedFlatOverlay = new GraphicsOverlay(); _drapedFlatOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.DrapedFlat; GraphicsOverlay relativeToSceneOverlay = new GraphicsOverlay(); relativeToSceneOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.RelativeToScene; MySceneView.GraphicsOverlays.Add(relativeToSceneOverlay); GraphicsOverlay relativeToSurfaceOverlay = new GraphicsOverlay(); relativeToSurfaceOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Relative; MySceneView.GraphicsOverlays.Add(relativeToSurfaceOverlay); GraphicsOverlay absoluteOverlay = new GraphicsOverlay(); absoluteOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Absolute; MySceneView.GraphicsOverlays.Add(absoluteOverlay); // Create point for graphic location. MapPoint sceneRelatedPoint = new MapPoint(-4.4610562, 48.3902727, 70, camera.Location.SpatialReference); MapPoint surfaceRelatedPoint = new MapPoint(-4.4609257, 48.3903965, 70, camera.Location.SpatialReference); // Create a red triangle symbol. var triangleSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Triangle, Color.FromArgb(255, 255, 0, 0), 10); // Create a text symbol for each elevation mode. TextSymbol drapedBillboardedText = new TextSymbol("DRAPED BILLBOARDED", Color.FromArgb(255, 0, 0, 255), 10, Esri.ArcGISRuntime.Symbology.HorizontalAlignment.Center, Esri.ArcGISRuntime.Symbology.VerticalAlignment.Middle); drapedBillboardedText.OffsetY += 20; TextSymbol drapedFlatText = new TextSymbol("DRAPED FLAT", Color.FromArgb(255, 0, 0, 255), 10, Esri.ArcGISRuntime.Symbology.HorizontalAlignment.Center, Esri.ArcGISRuntime.Symbology.VerticalAlignment.Middle); drapedFlatText.OffsetY += 20; TextSymbol relativeToSurfaceText = new TextSymbol("RELATIVE TO SURFACE", Color.FromArgb(255, 0, 0, 255), 10, Esri.ArcGISRuntime.Symbology.HorizontalAlignment.Center, Esri.ArcGISRuntime.Symbology.VerticalAlignment.Middle); relativeToSurfaceText.OffsetY += 20; TextSymbol relativeToSceneText = new TextSymbol("RELATIVE TO SCENE", Color.FromArgb(255, 0, 0, 255), 10, Esri.ArcGISRuntime.Symbology.HorizontalAlignment.Center, Esri.ArcGISRuntime.Symbology.VerticalAlignment.Middle); relativeToSceneText.OffsetY -= 20; TextSymbol absoluteText = new TextSymbol("ABSOLUTE", Color.FromArgb(255, 0, 0, 255), 10, Esri.ArcGISRuntime.Symbology.HorizontalAlignment.Center, Esri.ArcGISRuntime.Symbology.VerticalAlignment.Middle); absoluteText.OffsetY += 20; // Add the point graphic and text graphic to the corresponding graphics overlay. _drapedBillboardedOverlay.Graphics.Add(new Graphic(surfaceRelatedPoint, triangleSymbol)); _drapedBillboardedOverlay.Graphics.Add(new Graphic(surfaceRelatedPoint, drapedBillboardedText)); _drapedFlatOverlay.Graphics.Add(new Graphic(surfaceRelatedPoint, triangleSymbol)); _drapedFlatOverlay.Graphics.Add(new Graphic(surfaceRelatedPoint, drapedFlatText)); relativeToSceneOverlay.Graphics.Add(new Graphic(sceneRelatedPoint, triangleSymbol)); relativeToSceneOverlay.Graphics.Add(new Graphic(sceneRelatedPoint, relativeToSceneText)); relativeToSurfaceOverlay.Graphics.Add(new Graphic(surfaceRelatedPoint, triangleSymbol)); relativeToSurfaceOverlay.Graphics.Add(new Graphic(surfaceRelatedPoint, relativeToSurfaceText)); absoluteOverlay.Graphics.Add(new Graphic(surfaceRelatedPoint, triangleSymbol)); absoluteOverlay.Graphics.Add(new Graphic(surfaceRelatedPoint, absoluteText)); BillboardButton.Checked += BillboardedClick; FlatButton.Checked += FlatClick; }
private async void Initialize() { // Create scene Scene myScene = new Scene(Basemap.CreateImageryWithLabels()); // Set initial viewpoint myScene.InitialViewpoint = new Viewpoint(_observerPoint, 1000000); // Create the elevation source ElevationSource myElevationSource = new ArcGISTiledElevationSource(_elevationUri); // Add the elevation source to the scene myScene.BaseSurface.ElevationSources.Add(myElevationSource); // Create the building scene layer ArcGISSceneLayer mySceneLayer = new ArcGISSceneLayer(_buildingsUri); // Add the building layer to the scene myScene.OperationalLayers.Add(mySceneLayer); // Add the observer to the scene // Create a graphics overlay with relative surface placement; relative surface placement allows the Z position of the observation point to be adjusted GraphicsOverlay overlay = new GraphicsOverlay() { SceneProperties = new LayerSceneProperties(SurfacePlacement.Relative) }; // Create the symbol that will symbolize the observation point SimpleMarkerSceneSymbol symbol = new SimpleMarkerSceneSymbol(SimpleMarkerSceneSymbolStyle.Sphere, System.Drawing.Color.Red, 10, 10, 10, SceneSymbolAnchorPosition.Bottom); // Create the observation point graphic from the point and symbol _observerGraphic = new Graphic(_observerPoint, symbol); // Add the observer to the overlay overlay.Graphics.Add(_observerGraphic); // Add the overlay to the scene _mySceneView.GraphicsOverlays.Add(overlay); // Add the taxi to the scene // Create the model symbol for the taxi ModelSceneSymbol taxiSymbol = await ModelSceneSymbol.CreateAsync(new Uri(GetModelUri())); // Set the anchor position for the mode; ensures that the model appears above the ground taxiSymbol.AnchorPosition = SceneSymbolAnchorPosition.Bottom; // Create the graphic from the taxi starting point and the symbol _taxiGraphic = new Graphic(_points[0], taxiSymbol); // Add the taxi graphic to the overlay overlay.Graphics.Add(_taxiGraphic); // Create GeoElement Line of sight analysis (taxi to building) // Create the analysis _geoLine = new GeoElementLineOfSight(_observerGraphic, _taxiGraphic); // Apply an offset to the target. This helps avoid some false negatives _geoLine.TargetOffsetZ = 2; // Create the analysis overlay AnalysisOverlay myAnalysisOverlay = new AnalysisOverlay(); // Add the analysis to the overlay myAnalysisOverlay.Analyses.Add(_geoLine); // Add the analysis overlay to the scene _mySceneView.AnalysisOverlays.Add(myAnalysisOverlay); // Create a timer; this will enable animating the taxi var timer = new Timer(60); // Move the taxi every time the timer expires timer.Elapsed += AnimationTimer_Elapsed; // Keep the timer running continuously timer.AutoReset = true; // Start the timer timer.Start(); // Subscribe to TargetVisible events; allows for updating the UI and selecting the taxi when it is visible _geoLine.TargetVisibilityChanged += Geoline_TargetVisibilityChanged; // Add the scene to the view _mySceneView.Scene = myScene; }
public async void InitScene(string json, SceneView sceneView) { try { JsonReader jreader = new JsonTextReader(new System.IO.StringReader(json)); JObject jo = (JObject)JsonConvert.DeserializeObject(json); // 加载operationalLayers 图层 if (jo["operationalLayers"].Count() > 0) { int LayerCount = 1; for (int j = 0; j < jo["operationalLayers"].Count(); j++, LayerCount++) { string operational_title = jo["operationalLayers"][j]["title"].ToString(); string operational_layerType = jo["operationalLayers"][j]["layerType"].ToString(); if (operational_layerType.Equals("GroupLayer")) { if (jo["operationalLayers"][j]["layers"] != null && jo["operationalLayers"][j]["layers"].Count() > 0) { for (int i = 0; i < jo["operationalLayers"][j]["layers"].Count(); i++) { string GrouplLayers_title = jo["operationalLayers"][j]["layers"][i]["title"].ToString(); string GrouplLayers_url = jo["operationalLayers"][j]["layers"][i]["url"].ToString(); ArcGISSceneLayer Scenelayer = new ArcGISSceneLayer(new Uri(GrouplLayers_url)); sceneView.Scene.OperationalLayers.Add(Scenelayer); //Label lab = new Label { Content = $"图层{LayerCount} : {GrouplLayers_title}" }; //this.listLayer.Items.Add(lab); } } } else { string operational_url = jo["operationalLayers"][j]["url"].ToString(); ArcGISSceneLayer Scenelayer = new ArcGISSceneLayer(new Uri(operational_url)); sceneView.Scene.OperationalLayers.Add(Scenelayer); //Label lab = new Label { Content = $"图层{LayerCount} : {operational_title}" }; //this.listLayer.Items.Add(lab); } } } if (jo["baseMap"]["baseMapLayers"] != null && jo["baseMap"]["baseMapLayers"].Count() > 0) { // 加载底图 baseMap string baseMapLayers_layerType = jo["baseMap"]["baseMapLayers"][0]["layerType"].ToString(); if (baseMapLayers_layerType.Equals("ArcGISTiledMapServiceLayer")) { string baseMapLayers_url = jo["baseMap"]["baseMapLayers"][0]["url"].ToString(); ArcGISMapImageLayer basemap = new ArcGISMapImageLayer(new Uri(baseMapLayers_url)); Basemap map = new Basemap(basemap); sceneView.Scene.Basemap = map; } } // 加载高程 elevationLayers if (jo["baseMap"]["elevationLayers"] != null && jo["baseMap"]["elevationLayers"].Count() > 0) { for (int j = 0; j < jo["baseMap"]["elevationLayers"].Count(); j++) { string elevationLayer_url = jo["baseMap"]["elevationLayers"][j]["url"].ToString(); string elevationLayer_layerType = jo["baseMap"]["elevationLayers"][j]["layerType"].ToString(); var elevationSource = new ArcGISTiledElevationSource(new System.Uri(elevationLayer_url)); sceneView.Scene.BaseSurface.ElevationSources.Add(elevationSource); } } // 加载书签 slides if (jo["presentation"]["slides"] != null && jo["presentation"]["slides"].Count() >= 0) { int bookMarkCount = 1; for (int j = 0; j < jo["presentation"]["slides"].Count(); j++, bookMarkCount++) { string sttt = JsonConvert.SerializeObject(jo["presentation"]["slides"][j]["viewpoint"]); string bkname = jo["presentation"]["slides"][j]["title"]["text"].ToString(); string bkimage = jo["presentation"]["slides"][j]["thumbnail"]["url"].ToString(); Viewpoint vp = Viewpoint.FromJson(sttt); Bookmark bk = new Bookmark(bkname, vp); sceneView.Scene.Bookmarks.Add(bk); // Camera ca = new Camera(); // Label lab = new Label { Content = $"书签{bookMarkCount} : {bkname}" }; //lab.Tag = vp; //lab.MouseDown += Lab_MouseDown; // this.listbookMark.Items.Add(lab); //double slidesx = (double)jo["presentation"]["slides"][j]["viewpoint"]["camera"]["position"]["x"]; //double slidesy = (double)jo["presentation"]["slides"][j]["viewpoint"]["camera"]["position"]["y"]; //double slidesz = (double)jo["presentation"]["slides"][j]["viewpoint"]["camera"]["position"]["z"]; //double slides_heading = (double)jo["presentation"]["slides"][j]["viewpoint"]["camera"]["heading"]; //double slides_tilt = (double)jo["presentation"]["slides"][j]["viewpoint"]["camera"]["tilt"]; } } string initialState = JsonConvert.SerializeObject(jo["initialState"]["viewpoint"]); Viewpoint initialViewpoint = Viewpoint.FromJson(initialState); await sceneView.SetViewpointAsync(initialViewpoint, TimeSpan.FromSeconds(10)); } catch { } }