private async void Initialize() { // Create the layers. ArcGISSceneLayer devOne = new ArcGISSceneLayer(new Uri("https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/DevA_Trees/SceneServer")); FeatureLayer devTwo = new FeatureLayer(new Uri("https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/DevA_Pathways/FeatureServer/1")); ArcGISSceneLayer devThree = new ArcGISSceneLayer(new Uri("https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/DevB_BuildingShells/SceneServer")); ArcGISSceneLayer nonDevOne = new ArcGISSceneLayer(new Uri("https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/DevA_BuildingShells/SceneServer")); FeatureLayer nonDevTwo = new FeatureLayer(new Uri("https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/DevelopmentProjectArea/FeatureServer/0")); // Create the group layer and add sublayers. GroupLayer gLayer = new GroupLayer(); gLayer.Name = "Group: Dev A"; gLayer.Layers.Add(devOne); gLayer.Layers.Add(devTwo); gLayer.Layers.Add(devThree); // Create the scene with a basemap. MySceneView.Scene = new Scene(Basemap.CreateImagery()); // Add the top-level layers to the scene. MySceneView.Scene.OperationalLayers.Add(gLayer); MySceneView.Scene.OperationalLayers.Add(nonDevOne); MySceneView.Scene.OperationalLayers.Add(nonDevTwo); // Wait for all of the layers in the group layer to load. await Task.WhenAll(gLayer.Layers.ToList().Select(m => m.LoadAsync()).ToList()); // Zoom to the extent of the group layer. MySceneView.SetViewpoint(new Viewpoint(gLayer.FullExtent)); }
private void OnViewpointChanged(object sender, EventArgs e) { // Get the MapView or SceneView that sent the event GeoView sendingView = (GeoView)sender; // Only take action if this geoview is the one that the user is navigating. // Viewpoint changed events are fired when SetViewpoint is called; This check prevents a feedback loop if (sendingView.IsNavigating) { // If the MapView sent the event, update the SceneView's viewpoint if (sender is MapView) { // Get the viewpoint Viewpoint updateViewpoint = MyMapView.GetCurrentViewpoint(ViewpointType.CenterAndScale); // Set the viewpoint MySceneView.SetViewpoint(updateViewpoint); } else // Else, update the MapView's viewpoint { // Get the viewpoint Viewpoint updateViewpoint = MySceneView.GetCurrentViewpoint(ViewpointType.CenterAndScale); // Set the viewpoint MyMapView.SetViewpoint(updateViewpoint); } } }
private void Initialize() { // Create a scene for the sceneview. Scene myScene = new Scene(Basemap.CreateImagery()); MySceneView.Scene = myScene; // Create a geometry for the ground overlay. Envelope overlayGeometry = new Envelope(-123.066227926904, 44.04736963555683, -123.0796942287304, 44.03878298600624, SpatialReferences.Wgs84); // Create a KML Icon for the overlay image. KmlIcon overlayImage = new KmlIcon(_imageryUri); // Create the KML ground overlay. KmlGroundOverlay overlay = new KmlGroundOverlay(overlayGeometry, overlayImage); // Set the rotation of the ground overlay. overlay.Rotation = -3.046024799346924; // Create a KML dataset with the ground overlay as the root node. KmlDataset dataset = new KmlDataset(overlay); // Create a KML layer for the scene view. KmlLayer layer = new KmlLayer(dataset); // Add the layer to the map. MySceneView.Scene.OperationalLayers.Add(layer); // Move the viewpoint to the ground overlay. MySceneView.SetViewpoint(new Viewpoint(overlay.Geometry, new Camera(overlay.Geometry.Extent.GetCenter(), 1250, 45, 60, 0))); // Add an event handler for the on-screen slider. OpacitySlider.ValueChanged += (s, e) => { // Change the color of the KML ground overlay image to edit the alpha-value. (Other color values are left as-is in the original image.) overlay.Color = System.Drawing.Color.FromArgb((int)(e.NewValue), 0, 0, 0); // Make the value an integer (For the UI). OpacitySlider.Value = (int)OpacitySlider.Value; }; }
private void Initialize() { // Set up the basemap. MySceneView.Scene = new Scene(Basemap.CreateImageryWithLabels()); // Create the dataset. KmlDataset dataset = new KmlDataset(new Uri("https://www.arcgis.com/sharing/rest/content/items/600748d4464442288f6db8a4ba27dc95/data")); // Listen for network link control messages. // These should be shown to the user. dataset.NetworkLinkControlMessage += Dataset_NetworkLinkControlMessage; // Create the layer from the dataset. KmlLayer fileLayer = new KmlLayer(dataset); // Add the layer to the map. MySceneView.Scene.OperationalLayers.Add(fileLayer); // Zoom in to center the map on Germany. MySceneView.SetViewpoint(new Viewpoint(new MapPoint(8.150526, 50.472421, SpatialReferences.Wgs84), 20000000)); }
private async void Initialize() { // Create scene Scene myScene = new Scene(Basemap.CreateImageryWithLabels()); // 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); // Add the taxi to the scene // Create the model symbol for the taxi ModelSceneSymbol taxiSymbol = await ModelSceneSymbol.CreateAsync(new Uri(await 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 Windows.UI.Xaml.DispatcherTimer animationTimer = new Windows.UI.Xaml.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; // Set the viewpoint MySceneView.SetViewpoint(new Viewpoint(_observerPoint, 1000)); }