public MainWindow() { InitializeComponent(); MapPoint overlayLocation = null; //var ferneyTip = this.mapView.FindName("ferneyOverlay") as FrameworkElement; //// if the overlay element is found, set its position and make it visible //if (ferneyTip != null) //{ // overlayLocation = new Esri.ArcGISRuntime.Geometry.MapPoint(6.1081, 46.2558, Esri.ArcGISRuntime.Geometry.SpatialReferences.Wgs84); // Esri.ArcGISRuntime.Controls.MapView.SetViewOverlayAnchor(ferneyTip, overlayLocation); // // ferneyTip.Visibility = Visibility.Visible; //} //return; Callout c = new Callout(); c.CalloutTitle = "标题"; c.CalloutContent = "内容"; OverlayItemsControl f = new OverlayItemsControl(); f.Items.Add(c); mapView.Overlays.Items.Add(c); // if the overlay element is found, set its position and make it visible if (f != null) { overlayLocation = new Esri.ArcGISRuntime.Geometry.MapPoint(6.1081, 46.2558, Esri.ArcGISRuntime.Geometry.SpatialReferences.Wgs84); Esri.ArcGISRuntime.Controls.MapView.SetViewOverlayAnchor(c, overlayLocation); c.Visibility = Visibility.Visible; } }
private async void ViewButton_Click(object sender, RoutedEventArgs e) { originPoint = null; //Change button to 2D or 3D when button is clicked ViewButton.Content = FindResource(ViewButton.Content == FindResource("3D") ? "2D" : "3D"); if (ViewButton.Content == FindResource("2D")) { threeD = true; if (myScene == null) { //Create a new scene myScene = new Scene(Basemap.CreateNationalGeographic()); sceneView.Scene = myScene; // create an elevation source var elevationSource = new ArcGISTiledElevationSource(new System.Uri(ELEVATION_IMAGE_SERVICE)); // create a surface and add the elevation surface var sceneSurface = new Surface(); sceneSurface.ElevationSources.Add(elevationSource); // apply the surface to the scene sceneView.Scene.BaseSurface = sceneSurface; //Exercise 3: Open mobie map package (.mmpk) and add its operational layers to the scene var mmpk = await MobileMapPackage.OpenAsync(MMPK_PATH); if (mmpk.Maps.Count >= 0) { myMap = mmpk.Maps[0]; LayerCollection layerCollection = myMap.OperationalLayers; for (int i = 0; i < layerCollection.Count(); i++) { var thelayer = layerCollection[i]; myMap.OperationalLayers.Clear(); myScene.OperationalLayers.Add(thelayer); sceneView.SetViewpoint(myMap.InitialViewpoint); //Rotate the camera Viewpoint viewpoint = sceneView.GetCurrentViewpoint(ViewpointType.CenterAndScale); Esri.ArcGISRuntime.Geometry.MapPoint targetPoint = (MapPoint)viewpoint.TargetGeometry; Camera camera = sceneView.Camera.RotateAround(targetPoint, 45.0, 65.0, 0.0); await sceneView.SetViewpointCameraAsync(camera); } sceneView.Scene = myScene; bufferAndQuerySceneGraphics.SceneProperties.SurfacePlacement = SurfacePlacement.Draped; sceneView.GraphicsOverlays.Add(bufferAndQuerySceneGraphics); sceneRouteGraphics.SceneProperties.SurfacePlacement = SurfacePlacement.Draped; sceneView.GraphicsOverlays.Add(sceneRouteGraphics); } } //Exercise 1 Once the scene has been created hide the mapView and show the sceneView mapView.Visibility = Visibility.Hidden; sceneView.Visibility = Visibility.Visible; } else { threeD = false; sceneView.Visibility = Visibility.Hidden; mapView.Visibility = Visibility.Visible; } }
public Graphic MakeMapPointGraphic2(double X, double Y, int SR, int anAttributeValue1, string anAttributeValue2) { // This function constructs a new Graphic using: // (1) coordinate pairs (X, Y) // (2) a SpatialReference.WKID (SR) // (3) some Attribute values (anAttributeValue, anAttributeValue2) // Create a SpatialReference for the Graphic. Esri.ArcGISRuntime.Geometry.SpatialReference aSpatialReference = new Esri.ArcGISRuntime.Geometry.SpatialReference(SR); // Create a MapPoint object and set its SpatialReference and coordinate (X,Y) information. Esri.ArcGISRuntime.Geometry.MapPoint aMapPoint = new Esri.ArcGISRuntime.Geometry.MapPoint(X, Y, aSpatialReference); // Create a new instance of one Graphic and assign its Geometry. Graphic aGraphic = new Graphic(); aGraphic.Geometry = (Esri.ArcGISRuntime.Geometry.Geometry)aMapPoint; // Create a new instance of a SimpleMarkerSymbol and set its Color, Style, and Size Properties. SimpleMarkerSymbol aSimpleMarkerySymbol = new SimpleMarkerSymbol(); aSimpleMarkerySymbol.Color = Colors.Red; aSimpleMarkerySymbol.Style = SimpleMarkerStyle.Circle; aSimpleMarkerySymbol.Size = 20; aGraphic.Symbol = (Symbol)aSimpleMarkerySymbol; // Add some Attributes to the Graphic. aGraphic.Attributes.Add("Temperature", anAttributeValue1); aGraphic.Attributes.Add("Location", anAttributeValue2); // Dynamically wire-up the MouseRightButtonDown Event handler. // Return the created Graphic. return(aGraphic); }
public async void Zoom() { MapPoint point = new Esri.ArcGISRuntime.Geometry.MapPoint(12.5, 41.9, new SpatialReference(4326)); await mapView.SetViewAsync(point, 100000); }