3.6 Alter basemap

This commit is contained in:
PeterZhong 2024-10-12 10:58:26 +08:00
parent cb87a4a08d
commit 0618695c88
2 changed files with 32 additions and 0 deletions

View File

@ -26,5 +26,8 @@
<Border BorderBrush="#FF8B1D76" BorderThickness="2,2,2,2" HorizontalAlignment="Right" Height="180" Width="202" VerticalAlignment="Top" IsEnabled="False">
<esri:MapView x:Name="EagleMapView"/>
</Border>
<Border BorderBrush="#000000" BorderThickness="1" HorizontalAlignment="Right" Height="24" Width="202" VerticalAlignment="Top" IsEnabled="True" Margin="580,210,0,0" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}">
<ComboBox x:Name="BasemapChooser" HorizontalAlignment="Left" Height="24" Margin="9,-1,0,-1" VerticalAlignment="Top" Width="182" SelectionChanged="BasemapChooser_OnSelectionChanged" IsEnabled="True"/>
</Border>
</Grid>
</Window>

View File

@ -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<string, Basemap> _basemapOptions = new Dictionary<string, Basemap>()
{
{ "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];
}
}
}