无法为样式字典提供文件路径



我正在做一个。net项目,我必须将功能转换成图形,以显示它们与存储的符号。

我有一个独立的样式文件为。stylx和geodatabase文件为。goeddatabase .zip,我想利用它来显示我的样式文件的符号。

我成功地执行了下面的代码并显示了可能的映射。但是我无法访问存储在我驱动器上的样式库和地理数据库。

以下是我的文件规格

  • mil2525d.stylx一个用于ArcGIS Runtime 100.0的手写文件MIL-STD-2525D符号字典
  • militaryoverlay.geodatabase.zip-这是一个移动地理数据库从军事覆盖模板创建,用于ArcGIS运行时样品

的任何帮助
using System;
using System.Windows;
using ArcGISRuntime.Samples.Managers;
using Esri.ArcGISRuntime.Data;
using Esri.ArcGISRuntime.Geometry;
using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.Symbology;
namespace ArcGISRuntime.WPF.Samples.FeatureLayerDictionaryRenderer
{
[ArcGISRuntime.Samples.Shared.Attributes.Sample(
name: "Dictionary renderer with feature layer",
category: "Layers",
description: "Convert features into graphics to show them with mil2525d symbols.",
instructions: "Pan and zoom around the map. Observe the displayed military symbology on the map.",
tags: new[] { "military", "symbol" })]
[ArcGISRuntime.Samples.Shared.Attributes.OfflineData("c78b149a1d52414682c86a5feeb13d30", "e0d41b4b409a49a5a7ba11939d8535dc")]
public partial class FeatureLayerDictionaryRenderer
{
public FeatureLayerDictionaryRenderer()
{
InitializeComponent();
// Setup the control references and execute initialization
Initialize();
}
private async void Initialize()
{
// Create new Map with basemap
Map myMap = new Map(BasemapStyle.ArcGISTopographic);
// Provide Map to the MapView
MyMapView.Map = myMap;
// Get the path to the geodatabase
string geodbFilePath = GetGeodatabasePath();
// Load the geodatabase from local storage
Geodatabase baseGeodatabase = await Geodatabase.OpenAsync(geodbFilePath);
// Get the path to the symbol dictionary
string symbolFilepath = GetStyleDictionaryPath();
try
{
// Load the symbol dictionary from local storage
DictionarySymbolStyle symbolStyle = await DictionarySymbolStyle.CreateFromFileAsync(symbolFilepath);
// Add geodatabase features to the map, using the defined symbology
foreach (FeatureTable table in baseGeodatabase.GeodatabaseFeatureTables)
{
// Load the table
await table.LoadAsync();
// Create the feature layer from the table
FeatureLayer myLayer = new FeatureLayer(table);
// Load the layer
await myLayer.LoadAsync();
// Create a Dictionary Renderer using the DictionarySymbolStyle
DictionaryRenderer dictRenderer = new DictionaryRenderer(symbolStyle);
// Apply the dictionary renderer to the layer
myLayer.Renderer = dictRenderer;
// Add the layer to the map
myMap.OperationalLayers.Add(myLayer);
}
// Create geometry for the center of the map
MapPoint centerGeometry = new MapPoint(-13549402.587055, 4397264.96879385, SpatialReference.Create(3857));
// Set the map's viewpoint to highlight the desired content
MyMapView.SetViewpoint(new Viewpoint(centerGeometry, 201555));
}
catch (Exception e)
{
MessageBox.Show(e.ToString(), "Error");
}
}
}
}

如果您试图使用公共样本与您自己的数据,您可以简单地替换代码中的数据,如下所示:

// Get the path to the geodatabase
string geodbFilePath = "c:/path_to_gdb/mygdb.geodatabase";
// Load the geodatabase from local storage
Geodatabase baseGeodatabase = await Geodatabase.OpenAsync(geodbFilePath);
// Get the path to the symbol dictionary
string symbolFilepath = "c:/path_to_style/mystylx.stylx";

或修改GetGeodatabasePathGetStyleDictionaryPath方法来指向您的数据位置。

相关内容

  • 没有找到相关文章

最新更新