简体   繁体   English

WPF的ArcGIS运行时-缺少程序集参考?

[英]ArcGIS runtime for WPF - A missing assembly reference?

I have installed the ArcGIS Runtime SDK for .NET (100.1.0) 我已经安装了.NET(100.1.0)的ArcGIS Runtime SDK

I created a WPF app from the ArcGIS template (that should come with all the necessary assembly references...). 我从ArcGIS模板创建了WPF应用程序(该模板随附所有必需的程序集引用...)。

I have a "MapView" (my XAML file) containing a map to which I would simply like to add a layer to. 我有一个“ MapView”(我的XAML文件),其中包含我只想向其添加图层的地图。 I used the example from the API documentation . 我使用了API文档中的示例 My XAML is as follows: 我的XAML如下:

<Page x:Class="WpfApplication1.Views.MapView"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
  xmlns:local="clr-namespace:WpfApplication1.Views"
  xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013"
  mc:Ignorable="d" 
  d:DesignHeight="300" d:DesignWidth="300"
  Title="MapView">

<Grid>
    <Grid.Resources>
        <esri:SimpleLineSymbol x:Key="SLS" Color="Transparent" Width="1"/>
        <esri:SimpleLineSymbol x:Key="BlackSLS" Color="Black" Width="1"/>
    </Grid.Resources>
    <Grid>
        <esri:MapView x:Name="MyMapView" />                   
    </Grid>
</Grid>
</Page>

In code behind, I do the following after calling the InitializeComponent() method: 在后面的代码中,我在调用InitializeComponent()方法之后执行以下操作:

LocalMapService localMapService = new LocalMapService(@"..\..\..\samples-data\maps\water-distribution-network.mpk");
await localMapService.StartAsync();

ArcGISDynamicMapServiceLayer arcGISDynamicMapServiceLayer = new 
ArcGISDynamicMapServiceLayer()
{
    ID = "arcGISDynamicMapServiceLayer",
    ServiceUri = localMapService.UrlMapService,
};

MyMapView.Map.Layers.Add(arcGISDynamicMapServiceLayer);

At this point Visual Studio warns me "Map does not contain a definition of layer [...] are you missing a using directive or assembly reference?" 此时,Visual Studio警告我“地图不包含图层的定义,您是否缺少using指令或程序集引用?”

If I instead decide to add my layer directly from the XAML without writing any code behind: 如果我决定直接从XAML添加我的图层,而无需编写任何代码:

 <Page x:Class="WpfApplication1.Views.MapView"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
  xmlns:local="clr-namespace:WpfApplication1.Views"
  xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013"
  mc:Ignorable="d" 
  d:DesignHeight="300" d:DesignWidth="300"
  Title="MapView">

<Grid>
    <Grid.Resources>
        <esri:SimpleLineSymbol x:Key="SLS" Color="Transparent" Width="1"/>
        <esri:SimpleLineSymbol x:Key="BlackSLS" Color="Black" Width="1"/>
    </Grid.Resources>
    <Grid>
        <esri:MapView x:Name="MyMapView">`enter code here`
            <esri:Map>
                <esri:ArcGISDynamicMapServiceLayer Url=... />
            </esri:Map>
        </esri:MapView>                         
    </Grid>
</Grid>
</Page>

The designer now warns "the name ArcGISDynamicMapServiceLayer does not exist in namespace http://schemas.esri.com/arcgis/runtime/2013 " 设计人员现在警告“名称空间http://schemas.esri.com/arcgis/runtime/2013中不存在ArcGISDynamicMapServiceLayer名称”

What am I doing wrong? 我究竟做错了什么? It looks I'm not loading all the appropriate components of the API even though I'm using the SDK's WPF template... I'm confused. 看起来即使我使用的是SDK的WPF模板,我也没有加载API的所有适当组件...我很困惑。

I'm running Visual Studio 2015 Update 2 on MS Windows Server 2012 (if that is of any relevance!) 我正在MS Windows Server 2012上运行Visual Studio 2015 Update 2(如果有任何意义!)

The code that you are using is for 10.2 version of the ArcGIS Runtime for .NET. 您正在使用的代码适用于ArcGIS Runtime for .NET的10.2版。 You can see https://developers.arcgis.com/net/latest/wpf/guide/local-server.htm how to work with the local server in 100.1 release. 您可以在https://developers.arcgis.com/net/latest/wpf/guide/local-server.htm中了解如何在100.1版本中使用本地服务器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM