diff --git a/GisDevelop_Exp/MainWindow.xaml b/GisDevelop_Exp/MainWindow.xaml index 7e1eb87..baaca9f 100644 --- a/GisDevelop_Exp/MainWindow.xaml +++ b/GisDevelop_Exp/MainWindow.xaml @@ -16,6 +16,7 @@ + diff --git a/GisDevelop_Exp/MainWindow.xaml.cs b/GisDevelop_Exp/MainWindow.xaml.cs index fc1c338..4809bbb 100644 --- a/GisDevelop_Exp/MainWindow.xaml.cs +++ b/GisDevelop_Exp/MainWindow.xaml.cs @@ -16,6 +16,7 @@ using System.Windows.Navigation; using System.Windows.Shapes; using Esri.ArcGISRuntime.Geometry; using Esri.ArcGISRuntime.Portal; +using Esri.ArcGISRuntime.Rasters; using Esri.ArcGISRuntime.Security; using Esri.ArcGISRuntime.Symbology; using Esri.ArcGISRuntime.UI; @@ -447,5 +448,35 @@ namespace GisDevelop_Exp { m_CurOper = CURRENTOPERATION.IdentifyQuery; } + + private void Menu_OpenRaster_OnClick(object sender, RoutedEventArgs e) + { + OpenRaster(); + } + + private async void OpenRaster() + { + var aMap = new Map(BasemapStyle.ArcGISImagery); + await aMap.LoadAsync(); + string _slocalRasterPath = ""; + System.Windows.Forms.OpenFileDialog fileDialog = new System.Windows.Forms.OpenFileDialog(); + fileDialog.Filter = "栅格文件(*.tif)|*.tif"; + if (fileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) + { + _slocalRasterPath = fileDialog.FileName; + } + + if (System.IO.File.Exists(_slocalRasterPath)) + { + Raster raster = new Raster(_slocalRasterPath); + RasterLayer rasterLayer = new RasterLayer(raster); + aMap.OperationalLayers.Add(rasterLayer); + await rasterLayer.LoadAsync(); + + Viewpoint geodatabaseViewPoint = new Viewpoint(rasterLayer.FullExtent); + aMap.InitialViewpoint = geodatabaseViewPoint; + MainMapView.Map = aMap; + } + } } } \ No newline at end of file