private async void Initialize() { // Create a new map MyMapView.Map = new Map(Basemap.CreateLightGrayCanvas()); // Get the full path string geoPackagePath = GetGeoPackagePath(); // Open the GeoPackage GeoPackage myGeoPackage = await GeoPackage.OpenAsync(geoPackagePath); // Read the raster images and get the first one Raster gpkgRaster = myGeoPackage.GeoPackageRasters.FirstOrDefault(); // Make sure an image was found in the package if (gpkgRaster == null) { return; } // Create a layer to show the raster RasterLayer newLayer = new RasterLayer(gpkgRaster); await newLayer.LoadAsync(); // Set the viewpoint await MyMapView.SetViewpointAsync(new Viewpoint(newLayer.FullExtent)); // Add the image as a raster layer to the map (with default symbology) MyMapView.Map.OperationalLayers.Add(newLayer); }
private void Initialize() { // Create a light gray canvas map Map myMap = new Map(Basemap.CreateLightGrayCanvas()); // Create graphics overlay to display sketch geometry _sketchOverlay = new GraphicsOverlay(); MyMapView.GraphicsOverlays.Add(_sketchOverlay); // Assign the map to the MapView MyMapView.Map = myMap; // Fill the combo box with choices for the sketch modes (shapes) Array sketchModes = System.Enum.GetValues(typeof(SketchCreationMode)); foreach (object mode in sketchModes) { SketchModePicker.Items.Add(mode.ToString()); } SketchModePicker.SelectedIndex = 0; // Set a gray background color for Android if (Device.RuntimePlatform == Device.Android) { DrawToolsGrid.BackgroundColor = Color.Gray; } // Hack to get around linker being too aggressive - this should be done with binding. UndoButton.Command = MyMapView.SketchEditor.UndoCommand; RedoButton.Command = MyMapView.SketchEditor.RedoCommand; CompleteButton.Command = MyMapView.SketchEditor.CompleteCommand; }
private void SegmentButtonClicked(object sender, EventArgs e) { // Get the segmented button control that raised the event var buttonControl = sender as UISegmentedControl; // Get the selected segment in the control var selectedSegmentId = buttonControl.SelectedSegment; // Execute the appropriate action for the control if (selectedSegmentId == 0) { // Show basemap choices ShowBasemapList(); } else if (selectedSegmentId == 1) { // Show a list of available operational layers ShowLayerList(); } else if (selectedSegmentId == 2) { // Clear the map from the map view (allow the user to start over and save as a new portal item) _myMapView.Map = new Map(Basemap.CreateLightGrayCanvas()); } else if (selectedSegmentId == 3) { // Show the save map UI ShowSaveMapUI(); } // Unselect all segments (user might want to click the same control twice) buttonControl.SelectedSegment = -1; }
private async void Initialize() { // Create a new map. _myMapView.Map = new Map(Basemap.CreateLightGrayCanvas()); // Get the GeoPackage path. string geoPackagePath = DataManager.GetDataFolder("68ec42517cdd439e81b036210483e8e7", "AuroraCO.gpkg"); // Open the GeoPackage. GeoPackage geoPackage = await GeoPackage.OpenAsync(geoPackagePath); // Read the raster images and get the first one. Raster gpkgRaster = geoPackage.GeoPackageRasters.FirstOrDefault(); // Make sure an image was found in the package. if (gpkgRaster == null) { return; } // Create a layer to show the raster. RasterLayer newLayer = new RasterLayer(gpkgRaster); await newLayer.LoadAsync(); // Set the viewpoint. await _myMapView.SetViewpointAsync(new Viewpoint(newLayer.FullExtent)); // Add the image as a raster layer to the map (with default symbology). _myMapView.Map.OperationalLayers.Add(newLayer); }
private void Initialize() { // Create new Map with basemap. Map myMap = new Map(Basemap.CreateLightGrayCanvas()); // Create envelope to be used as a target extent for map's initial viewpoint. Envelope myEnvelope = new Envelope(-6603299.491810, 1679677.742046, 9002253.947487, 8691318.054732, SpatialReferences.WebMercator); // Set the initial viewpoint for map. myMap.InitialViewpoint = new Viewpoint(myEnvelope); // Provide used Map to the MapView. _myMapView.Map = myMap; // Set the selection color. _myMapView.SelectionProperties.Color = Color.Cyan; // Create Uri for the feature service. Uri featureServiceUri = new Uri( "https://services1.arcgis.com/4yjifSiIG17X0gW4/arcgis/rest/services/GDP_per_capita_1960_2016/FeatureServer/0"); // Initialize feature table using a URL to feature server. ServiceFeatureTable featureTable = new ServiceFeatureTable(featureServiceUri); // Initialize a new feature layer based on the feature table. _featureLayer = new FeatureLayer(featureTable); // Add the layer to the map. myMap.OperationalLayers.Add(_featureLayer); }
private void Initialize() { // Create a light gray canvas map Map myMap = new Map(Basemap.CreateLightGrayCanvas()); // Create graphics overlay to display sketch geometry _sketchOverlay = new GraphicsOverlay(); _myMapView.GraphicsOverlays.Add(_sketchOverlay); // Assign the map to the MapView _myMapView.Map = myMap; // Set the sketch editor configuration to allow vertex editing, resizing, and moving SketchEditConfiguration config = _myMapView.SketchEditor.EditConfiguration; config.AllowVertexEditing = true; config.ResizeMode = SketchResizeMode.Uniform; config.AllowMove = true; // Listen to the sketch editor tools CanExecuteChange so controls can be enabled/disabled _myMapView.SketchEditor.UndoCommand.CanExecuteChanged += CanExecuteChanged; _myMapView.SketchEditor.RedoCommand.CanExecuteChanged += CanExecuteChanged; _myMapView.SketchEditor.CompleteCommand.CanExecuteChanged += CanExecuteChanged; // Listen to collection changed event on the graphics overlay to enable/disable controls that require a graphic _sketchOverlay.Graphics.CollectionChanged += GraphicsChanged; }
private void ApplyBasemap(string basemapName) { // Set the basemap for the map according to the user's choice in the list box Map myMap = MyMapView.Map; switch (basemapName) { case "Light Gray": // Set the basemap to Light Gray Canvas myMap.Basemap = Basemap.CreateLightGrayCanvas(); break; case "Topographic": // Set the basemap to Topographic myMap.Basemap = Basemap.CreateTopographic(); break; case "Streets": // Set the basemap to Streets myMap.Basemap = Basemap.CreateStreets(); break; case "Imagery": // Set the basemap to Imagery myMap.Basemap = Basemap.CreateImagery(); break; case "Ocean": // Set the basemap to Oceans myMap.Basemap = Basemap.CreateOceans(); break; } }
private void Initialize() { // Create a light gray canvas map Map myMap = new Map(Basemap.CreateLightGrayCanvas()); // Create graphics overlay to display sketch geometry _sketchOverlay = new GraphicsOverlay(); MyMapView.GraphicsOverlays.Add(_sketchOverlay); // Assign the map to the MapView MyMapView.Map = myMap; // Fill the combo box with choices for the sketch modes (shapes) SketchModeComboBox.ItemsSource = System.Enum.GetValues(typeof(SketchCreationMode)); SketchModeComboBox.SelectedIndex = 0; // Set the sketch editor configuration to allow vertex editing, resizing, and moving var config = MyMapView.SketchEditor.EditConfiguration; config.AllowVertexEditing = true; config.ResizeMode = SketchResizeMode.Uniform; config.AllowMove = true; // Set the sketch editor as the page's data context this.DataContext = MyMapView.SketchEditor; }
private void SegmentButtonClicked(object sender, EventArgs e) { // Get the segmented button control that raised the event. var buttonControl = sender as UISegmentedControl; switch (buttonControl.SelectedSegment) { case 0: // Clear the map from the map view (allow the user to start over and save as a new portal item). _myMapView.Map = new Map(Basemap.CreateLightGrayCanvas()); break; case 1: // Show basemap choices. ShowBasemapList(); break; case 2: // Show a list of available operational layers. ShowLayerList(); break; case 3: // Show the save map UI. ShowSaveMapUi(); break; } // Deselect all segments (user might want to click the same control twice). buttonControl.SelectedSegment = -1; }
private void CreateNewMap() { // Create new Map with a light gray canvas basemap Map myMap = new Map(Basemap.CreateLightGrayCanvas()); // Add the Map to the MapView MyMapView.Map = myMap; }
private void Initialize() { // Create new Map with basemap Map myMap = new Map(Basemap.CreateLightGrayCanvas()); // Show map in the MapView _myMapView.Map = myMap; }
private void DisplayDefaultMap() { // Create a new light gray canvas Map Map myMap = new Map(Basemap.CreateLightGrayCanvas()); // Assign Map to the MapView MyMapView.Map = myMap; }
private void Initialize() { // Show a map with basemap by default. _myMapView.Map = new Map(Basemap.CreateLightGrayCanvas()); // Update the authentication settings. UpdateAuthenticationManager(); }
private void DisplayDefaultMap() { // Create a new Map instance Map myMap = new Map(Basemap.CreateLightGrayCanvas()); // Provide Map to the MapView MyMapView.Map = myMap; }
private void Initialize() { // Show a light gray canvas basemap by default. _myMapView.Map = new Map(Basemap.CreateLightGrayCanvas()); // Prompt the user for OAuth settings. ShowOAuthPropsUi(); }
private void Initialize() { // Create a new Map instance Map myMap = new Map(Basemap.CreateLightGrayCanvas()); // Provide default Map to the MapView _myMapView.Map = myMap; }
private void Initialize() { // Create new Map with basemap Map myMap = new Map(Basemap.CreateLightGrayCanvas()); // Provide used Map to the MapView _myMapView.Map = myMap; }
private void Initialize() { // Remove the API key. ApiKeyManager.DisableKey(); // Show a light gray canvas basemap by default. _myMapView.Map = new Map(Basemap.CreateLightGrayCanvas()); }
// 改变底图 private void ChangeBaseMap_list_SelectionChanged(object sender, SelectionChangedEventArgs e) { Map myMap = myMapView.Map; switch (ChangeBaseMap_list.SelectedIndex) { case 0: myMap.Basemap = Basemap.CreateDarkGrayCanvasVector(); myMapView_Eagle.Map.Basemap = Basemap.CreateDarkGrayCanvasVector(); break; case 1: myMap.Basemap = Basemap.CreateImagery(); myMapView_Eagle.Map.Basemap = Basemap.CreateImagery(); break; case 2: myMap.Basemap = Basemap.CreateImageryWithLabels(); myMapView_Eagle.Map.Basemap = Basemap.CreateImageryWithLabels(); break; case 3: myMap.Basemap = Basemap.CreateTerrainWithLabels(); myMapView_Eagle.Map.Basemap = Basemap.CreateTerrainWithLabels(); break; case 4: myMap.Basemap = Basemap.CreateLightGrayCanvas(); myMapView_Eagle.Map.Basemap = Basemap.CreateLightGrayCanvas(); break; case 5: myMap.Basemap = Basemap.CreateTopographic(); myMapView_Eagle.Map.Basemap = Basemap.CreateTopographic(); break; case 6: myMap.Basemap = Basemap.CreateNationalGeographic(); myMapView_Eagle.Map.Basemap = Basemap.CreateNationalGeographic(); break; case 7: myMap.Basemap = Basemap.CreateNavigationVector(); myMapView_Eagle.Map.Basemap = Basemap.CreateNavigationVector(); break; case 8: myMap.Basemap = Basemap.CreateOceans(); myMapView_Eagle.Map.Basemap = Basemap.CreateOceans(); break; case 9: myMap.Basemap = Basemap.CreateStreets(); myMapView_Eagle.Map.Basemap = Basemap.CreateStreets(); break; } }
private void ClearMapClicked(object sender, RoutedEventArgs e) { // Create a new map (will not have an associated PortalItem) MyMapView.Map = new Map(Basemap.CreateLightGrayCanvas()); // Reset UI to be consistent with map BasemapListBox.SelectedIndex = 0; OperationalLayerListBox.SelectedIndex = -1; }
private void Initialize() { // Create and show a light gray canvas basemap. _myMapView.Map = new Map(Basemap.CreateLightGrayCanvas()); // Create graphics overlay to display sketch geometry. _sketchOverlay = new GraphicsOverlay(); _myMapView.GraphicsOverlays.Add(_sketchOverlay); }
private async void Initialize() { // Create a map and add it to the view MyMapView.Map = new Map(Basemap.CreateLightGrayCanvas()); try { // LocalServer must not be running when setting the data path. if (LocalServer.Instance.Status == LocalServerStatus.Started) { await LocalServer.Instance.StopAsync(); } // Set the local data path - must be done before starting. On most systems, this will be C:\EsriSamples\AppData. // This path should be kept short to avoid Windows path length limitations. string tempDataPathRoot = Directory.GetParent(Environment.GetFolderPath(Environment.SpecialFolder.Windows)).FullName; string tempDataPath = Path.Combine(tempDataPathRoot, "EsriSamples", "AppData"); Directory.CreateDirectory(tempDataPath); // CreateDirectory won't overwrite if it already exists. LocalServer.Instance.AppDataPath = tempDataPath; // Start the local server instance await LocalServer.Instance.StartAsync(); // Get the path to the map package that will be served string datapath = GetDataPath(); // Create the Map Service from the data _localMapService = new LocalMapService(datapath); // Start the feature service await _localMapService.StartAsync(); // Get the url to the map service Uri myServiceUri = _localMapService.Url; // Create the layer from the url ArcGISMapImageLayer myImageLayer = new ArcGISMapImageLayer(myServiceUri); // Add the layer to the map MyMapView.Map.OperationalLayers.Add(myImageLayer); // Wait for the layer to load await myImageLayer.LoadAsync(); // Set the viewpoint on the map to show the data MyMapView.SetViewpoint(new Viewpoint(myImageLayer.FullExtent)); } catch (Exception ex) { var localServerTypeInfo = typeof(LocalMapService).GetTypeInfo(); var localServerVersion = FileVersionInfo.GetVersionInfo(localServerTypeInfo.Assembly.Location); var dlg = new MessageDialog2($"Please ensure that local server {localServerVersion.FileVersion} is installed prior to using the sample. The download link is in the description. Message: {ex.Message}", "Local Server failed to start"); _ = dlg.ShowAsync(); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { // 绘制层 myMapView.GraphicsOverlays.Add(graphicsOverlay); // 鹰眼的底图 myMapView_Eagle.Map = new Map(Basemap.CreateTopographic()); // 主地图的底图(因为一次地图错误——重复载入底图导致进程中断 才添加的) myMapView.Map = new Map(Basemap.CreateTopographic()); // 底图的列表 ChangeBaseMap_list.ItemsSource = new List <ListBoxItem>() { new ListBoxItem() { Content = "DarkGrayCanvasVector" }, new ListBoxItem() { Content = "Imagery" }, new ListBoxItem() { Content = "ImageryWithLabels" }, new ListBoxItem() { Content = "TerrainWithLabels" }, new ListBoxItem() { Content = "LightGrayCanvas" }, new ListBoxItem() { Content = "Topographic" }, new ListBoxItem() { Content = "NationalGeographic" }, new ListBoxItem() { Content = "NavigationVector" }, new ListBoxItem() { Content = "Oceans" }, new ListBoxItem() { Content = "Streets" }, }; // 初始化底图2 myMapView2.Map = new Map(Basemap.CreateLightGrayCanvas()); }
private void Initialize() { BasemapListView.ItemsSource = _basemapNames; LayerListView.ItemsSource = _operationalLayerUrls; // Show a plain gray map in the map view MyMapView.Map = new Map(Basemap.CreateLightGrayCanvas()); // Update the extent labels whenever the view point (extent) changes MyMapView.ViewpointChanged += (s, evt) => UpdateViewExtentLabels(); }
private void Initialize() { // Create a new Map instance to display by default Map myMap = new Map(Basemap.CreateLightGrayCanvas()); // Provide used Map to the MapView _myMapView.Map = myMap; // Prompt the user for OAuth settings ShowOAuthPropsUI(); }
private void Initialize() { // Create new Map with a light gray canvas basemap Map myMap = new Map(Basemap.CreateLightGrayCanvas()); // Add the Map to the MapView _myMapView.Map = myMap; // Set up the challenge handler and OAuth authorization UpdateAuthenticationManager(); }
private void Initialize() { // Create new Map with a light gray canvas basemap var myMap = new Map(Basemap.CreateLightGrayCanvas()); // Add the Map to the MapView _myMapView.Map = myMap; // Prompt the user for OAuth settings ShowOAuthPropsUI(); }
private void Initialize() { // Remove API key. ApiKeyManager.DisableKey(); // Create new Map with basemap Map myMap = new Map(Basemap.CreateLightGrayCanvas()); // Provide used Map to the MapView _myMapView.Map = myMap; }
private void Initialize() { // Create the map with a default basemap. _myMapView.Map = new Map(Basemap.CreateLightGrayCanvas()); // Create and add a graphics overlay. GraphicsOverlay overlay = new GraphicsOverlay(); _myMapView.GraphicsOverlays.Add(overlay); // Create the original geometry: some points along a river. PointCollection points = CreateShipPoints(); // Show the original geometry as red dots on the map. Multipoint originalMultipoint = new Multipoint(points); Graphic originalPointsGraphic = new Graphic(originalMultipoint, new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Color.Red, 7)); overlay.Graphics.Add(originalPointsGraphic); // Show a dotted red line connecting the original points. _originalPolyline = new Polyline(points); Graphic originalPolylineGraphic = new Graphic(_originalPolyline, new SimpleLineSymbol(SimpleLineSymbolStyle.Dot, Color.Red, 3)); overlay.Graphics.Add(originalPolylineGraphic); // Show the result (densified or generalized) points as magenta dots on the map. _resultPointGraphic = new Graphic { Symbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Color.Magenta, 7), ZIndex = 999 }; overlay.Graphics.Add(_resultPointGraphic); // Connect the result points with a magenta polyline. _resultPolylineGraphic = new Graphic { Symbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Magenta, 3), ZIndex = 1000 }; overlay.Graphics.Add(_resultPolylineGraphic); // Listen for changes in state. _segmentLengthSlider.ProgressChanged += (o, e) => UpdateGeometry("Densify", _segmentLengthSlider.Progress + 100, _deviationSlider.Progress + 1); _deviationSlider.ProgressChanged += (o, e) => UpdateGeometry("Generalize", _segmentLengthSlider.Progress + 100, _deviationSlider.Progress + 1); // Center the map. _myMapView.SetViewpointGeometryAsync(_originalPolyline.Extent, 100); }
private void ClearMapClicked(object sender, RoutedEventArgs e) { // Create a new map (will not have an associated PortalItem) MyMapView.Map = new Map(Basemap.CreateLightGrayCanvas()); // Reset the basemap selection in the UI BasemapListBox.SelectedIndex = 0; // Reset the layer selection in the UI; OperationalLayerListBox.SelectedIndex = -1; // Reset the extent labels UpdateViewExtentLabels(); }