From 0618695c8891d9301fcbab7317e231252d146d2f Mon Sep 17 00:00:00 2001 From: PeterZhong Date: Sat, 12 Oct 2024 10:58:26 +0800 Subject: [PATCH] 3.6 Alter basemap --- GisDevelop_Exp/MainWindow.xaml | 3 +++ GisDevelop_Exp/MainWindow.xaml.cs | 29 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/GisDevelop_Exp/MainWindow.xaml b/GisDevelop_Exp/MainWindow.xaml index b875cc1..3fa055f 100644 --- a/GisDevelop_Exp/MainWindow.xaml +++ b/GisDevelop_Exp/MainWindow.xaml @@ -26,5 +26,8 @@ + + + diff --git a/GisDevelop_Exp/MainWindow.xaml.cs b/GisDevelop_Exp/MainWindow.xaml.cs index e82d756..9099f67 100644 --- a/GisDevelop_Exp/MainWindow.xaml.cs +++ b/GisDevelop_Exp/MainWindow.xaml.cs @@ -32,12 +32,35 @@ namespace GisDevelop_Exp private string _statesUrl = "https://services.arcgis.com/jIL9msH9OI208GCb/arcgis/rest/services/USA_Daytime_Population_2016/FeatureServer/0"; private ServiceFeatureTable _featureTable; + + private readonly Dictionary _basemapOptions = new Dictionary() + { + { "Streets (Raster)", new Basemap(BasemapStyle.OSMStreets) }, + { "Streets (Vector)", new Basemap(BasemapStyle.OSMStreetsRelief) }, + { "Streets - Night (Vector)", new Basemap(BasemapStyle.ArcGISStreetsNight) }, + { "Imagery (Raster)", new Basemap(BasemapStyle.ArcGISImagery) }, + { "Imagery with Labels (Raster)", new Basemap(BasemapStyle.ArcGISImageryLabels) }, + { "Imagery with Labels (Vector)", new Basemap(BasemapStyle.ArcGISImageryStandard) }, + { "Dark Gray Canvas (Vector)", new Basemap(BasemapStyle.ArcGISDarkGray) }, + { "Light Gray Canvas (Raster)", new Basemap(BasemapStyle.ArcGISLightGray) }, + { "Light Gray Canvas (Vector)", new Basemap(BasemapStyle.ArcGISLightGrayBase) }, + { "Navigation (Vector)", new Basemap(BasemapStyle.ArcGISNavigation) }, + { "OpenStreetMap (Raster)", new Basemap(BasemapStyle.OSMNavigation) } + }; public MainWindow() { InitializeComponent(); + Initialize(); EagleMapView.Map = new Map(BasemapStyle.ArcGISImageryStandard); } + private void Initialize() + { + MainMapView.Map = new Map(_basemapOptions.Values.First()); + BasemapChooser.ItemsSource = _basemapOptions.Keys; + BasemapChooser.SelectedIndex = 0; + } + private void Menu_OpenShp_Click(object sender, RoutedEventArgs e) { OpenShp(); @@ -194,5 +217,11 @@ namespace GisDevelop_Exp MainMapView.Map = pMap; MainMapView.SelectionProperties.Color = Color.Cyan; } + + private void BasemapChooser_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + var selectedBasemapTitle = e.AddedItems[0].ToString(); + MainMapView.Map.Basemap = _basemapOptions[selectedBasemapTitle]; + } } }