Search code examples
c#wpfarcgisshapefileesri

Add Shapefile to Map with ESRI.ArcGISRuntime in a WPF application


Im trying to add a Shapefile to my Esri Map in a WPF application. I'm using the ESRI.ArcGISRuntime Nuget Version 10.2.7.1234. I stick to the description by the ArcGIS website (http://resources.arcgis.com/en/help/runtime-wpf/samples/index.html#/Add_Shapefiles_and_Rasters/02q20000004z000000/).

But at this point

                ArcGISLocalDynamicMapServiceLayer arcGisLocalDynamicMapServiceLayer = null;
                arcGisLocalDynamicMapServiceLayer = new ArcGISLocalDynamicMapServiceLayer(localMapService)
                {                        
                    ID = "Workspace: " + (new DirectoryInfo(directoryPath)).Name,                                          
                    EnableDynamicLayers = true,
                };

I am unable to create an instance of the ArcGISLocalDynamicMapServiceLayer because it isn't available ("The type or namespace name 'ArcGISLocalDynamicMapServiceLayer' could not be found").

Is there an alternative I can use or how dow i solve this problem?


Solution

  • The layer you are trying to use is part of the LocalServer assembly which you probably didn't reference. However in 10.2.x you don't need to use LocalServer. You can just use a ShapefileTable attached to a FeatureLayer. There's an example for that here:

    https://github.com/Esri/arcgis-runtime-samples-dotnet/blob/10.2.7/src/Desktop/ArcGISRuntimeSamplesDesktop/Samples/FeatureLayers/FeatureLayerFromShapefile.xaml.cs

    https://github.com/Esri/arcgis-runtime-samples-dotnet/blob/10.2.7/src/Desktop/ArcGISRuntimeSamplesDesktop/Samples/FeatureLayers/FeatureLayerFromShapefile.xaml

    The main code is the LoadShapefile() method