ArcGIS Runtime WPF(.net C#)开发简明教程 2 ArcGIS Runtime 加载 MPKX地图包
ArcGIS Runtime .net(WPF)开发-初识 & 第一个项目
解决方案管理器里找到ArcGISLocalServer_100.9.AGSDeployment,如果没有,需要点击显示所有文件,或去代码目录下记事本打开
找到图上所示的位置,enabled改成true
项目的生成平台不能是x86,只能是x64或any CPU
程序运行目录路径不能太多层太长,因为LocalServer100.9下有8层以上目录加上文件名140以上字符,而windows文件路径长度好像是260的限制,太长会导致文件无法复制
默认是false,必须手动改下,不然不支持mpkx
LocalServer100.9目录大小1.73G
nuget包需要Esri.ArcGISRuntime.LocalServices
然后在初始化时调用
Esri.ArcGISRuntime.LocalServices.LocalServerEnvironment.Initialize();
代码加载MPKX地图包
LocalFeatureService featureService = new LocalFeatureService(@"D:\map.mpkx"); // Start the local service. await featureService.StartAsync(); // If the service was not started successfully, report status and return. if (featureService.Status != LocalServerStatus.Started) { MessageBox.Show("Local Server could not be started.", "Error"); return; } // If the service is started, get the service URL. string featureServiceUrl = featureService.Url.AbsoluteUri; // Create a new service feature table from the dataset with index 0. ServiceFeatureTable localServiceTable = new ServiceFeatureTable(new Uri(featureServiceUrl + "/0")); // Create a new feature layer to display the features in the table. FeatureLayer featureLyr = new FeatureLayer(localServiceTable); Basemap bm = new Basemap(featureLyr); MyMapView.Map = new Map(bm);