1.在WPF项目中通过nuget添加Esri.ArcGISRuntime.WPF
2.在XAML文件头添加命名空间xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013"
,再添加控件<esri:MapView x:Name="mapView"/>
3.在xaml.cs文件中添加授权码,只有标准版以上的授权码才能加载离线文件。(以下授权码不是真实有效的)
string licenseKey = "runtimeadvanced,1000,rud12345678,none,12345678";
string[] extensions = { "runtimeanalysis,1000,rud12345678,none,12345678",
"runtimesmpe,1000,rud12345678,none,12345678",
"runtimesmpj,1000,rud12345678,none,12345678",
"runtimesmpla,1000,rud12345678,none,12345678",
"runtimesmpmea,1000,rud12345678,none,12345678",
"runtimesmpna,1000,rud12345678,none,12345678"
};
Esri.ArcGISRuntime.ArcGISRuntimeEnvironment.SetLicense(licenseKey, extensions);
4.添加基础层
string url = "http://services.arcgisonline.com/arcgis/rest/services/World_Topo_Map/MapServer";
ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(new Uri(url));
mapView.Map = new Map(new Basemap(baseLayer));
5.添加离线图像文件,ArcGIS Runtime支持多种离线文件格式,可参考官方文档:https://developers.arcgis.com/net/latest/wpf/guide/work-with-offline-layers.htm
示例GeoTIFF文件下载地址:https://download.osgeo.org/geotiff/samples/made_up/ilatlon_float.tif
string fn = "ilatlon_float.tif";
RasterLayer newRasterLayer = new RasterLayer(fn);
mapView.Map.OperationalLayers.Add(newRasterLayer);
newRasterLayer.LoadAsync().Wait();
mapView.SetViewpointGeometryAsync(newRasterLayer.FullExtent);
6.运行结果如下图
ArcGIS加载离线地图文件