1

I have installed the ArcGIS Runtime SDK for .NET (100.1.0)

I created a WPF app from the ArcGIS template (that should come with all the necessary assembly references...).

I have a "MapView" (my XAML file) containing a map to which I would simply like to add a layer to. I used the example from the API documentation. My XAML is as follows:

<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:

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?"

If I instead decide to add my layer directly from the XAML without writing any code behind:

 <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"

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.

I'm running Visual Studio 2015 Update 2 on MS Windows Server 2012 (if that is of any relevance!)

harveyAJ
  • 833
  • 1
  • 11
  • 26

1 Answers1

2

The code that you are using is for 10.2 version of the ArcGIS Runtime for .NET. 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.

  • 1
    The error is correct. That class doesn't exist in in v100.1. You're probably looking for this class: "Esri.ArcGISRuntime.Mapping.ArcGISTiledLayer" – dotMorten Dec 04 '17 at 19:07
  • Indeed the stuff that I was trying to use was only available in the v10.2.7 (and prior) release. I uninstalled v100.1.0.0 of the SDK and installed v10.2.7 instead. Why so many functionalities that were present in previous version(s) are now missing? For instance, how do you now programatically add a layer to a map? – harveyAJ Dec 04 '17 at 19:10
  • @dotMorten I'm referencing ArcGIS runtime v100.1.0.0 in my project but can't access the namespace you specified – harveyAJ Dec 04 '17 at 19:16
  • In v100 family we separated Local Server functionality from the basic install to make it more modular. You still have the same functionality there though. – Antti Kajanus Dec 05 '17 at 09:44
  • Since the v100 series is the new major version of the product, the API isn't the same as previous generations (ie. 10.2 series). You can easily add the layer to the map by using `ArcGISMapImageLayer localServiceLayer = new ArcGISMapImageLayer(mapServiceUrl); MyMapView.Map.OperationalLayers.Add(localServiceLayer);` – Antti Kajanus Dec 05 '17 at 09:51