AnsweredAssumed Answered

ArcGIS Runtime SDK for .NET problem loading shapefile

Question asked by KingOnTheHill on Aug 2, 2015
Latest reply on Sep 17, 2015 by KingOnTheHill

I am moving from ArcGIS WPF to  ArcGIS .NET.

When I add  shapefiles to the map layer in the .NET version the  backdrop ArcGISTiledMapServiceLayer disappears.

Can anybody tell me how to correct it?

I use Visual Studio 2013, VB.NET and Esri.ArcGISRuntime 10.2.6.0.

Here is the code:

 

XAML

 

<Window x:Class="MainWindow"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    Title="MainWindow" Height="600" Width="800"

    xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013">

    <Grid>

                <!-- A MapView Control to display various GIS layers. -->

        <esri:MapView x:Name="MapView1" Width="662" Height="507" VerticalAlignment="Top" Margin="2,2,2,2">

 

            <!-- A Map. -->

            <esri:Map  x:Name="Map1" >

 

                <!-- Add a backdrop ArcGISTiledMapServiceLayer-->

                <esri:ArcGISTiledMapServiceLayer ID="myArcGISTiledMapServiceLayer"

                    ServiceUri="http://services.arcgisonline.com/ArcGIS/rest/services/Ocean_Basemap/MapServer" />

            </esri:Map>

        </esri:MapView>

    </Grid>

</Window>

 

VB

 

' NOTE: The Shapefile that was used in this sample was obtained from the US Census at the following Url:

' http://www.census.gov/geo/maps-data/data/tiger-data.html <-- expand the '2010 Census' | 'Demographic Profile1 - Shapefile Format' section and click on the 'States' link  

' The downloaded file (State_2010Census_DP1.zip) was then unzipped to reveal the 'C:\TestData\State_2010Census_DP1' directory structure that contains

' the Shapefile (.shp, .dbf, .shx, and .prj) and a metadata file (DP_TableDescriptions.xls) that describes the attributes fields in the Shapefile.

 

Class MainWindow

 

    Public Sub New()

 

        ' This call is required by the designer.

        InitializeComponent()

 

        ' Set the initial extent to that of the continental US.

        Dim myEnvelope As Esri.ArcGISRuntime.Geometry.Envelope = New Esri.ArcGISRuntime.Geometry.Envelope(-125.72, 18.73, -66.3, 55.29)

        MapView1.Map.InitialViewpoint = New Esri.ArcGISRuntime.Controls.Viewpoint(myEnvelope)

 

        ' CAUTION: Local disk based FeatureLayers DO NOT re-project to match the Map's SpatialReference!

        ' It is recommended to always set the SpatialReference for the Map when using a FeatureLayer based on a local disk based FeatureTable such as

        ' a ShapefileTable or a GeodatabaseFeatureTable. The reason is that the visual elements of the FeatureLayer may not display if the Shapefile or

        ' GeodatabaseFeatureTable are not based on the SpatialReference WKID of 3787 (aka. Web Mercator). By specifying the Map's SpatialReference to

        ' be exactly the same at the ShapefileTable or GeodatabaseFeatureTable, you will be assured that it displays visually in the Map.

        ' NOTE: If the FeatureLayer is based on an ArcGIS Server web ServiceFeatureTable, then re-projection of the data automatically occurs

        ' to match the SpatialReference of the Map.

        MapView1.Map.SpatialReference = Esri.ArcGISRuntime.Geometry.SpatialReference.Create(4269)

 

    End Sub

 

    Private Async Sub MainWindow_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded

        ' Create a ShapefileTable from the .shp file.

        Dim myShapefileTable As Esri.ArcGISRuntime.Data.ShapefileTable = Await Esri.ArcGISRuntime.Data.ShapefileTable.OpenAsync("C:\TestData\State_2010Census_DP1\State_2010Census_DP1.shp")

 

        ' Create a new FeatureLayer based upon the ShapefileTable. Set its .ID and .DisplayName properties.

        Dim myFeatureLayer As Esri.ArcGISRuntime.Layers.FeatureLayer = New Esri.ArcGISRuntime.Layers.FeatureLayer(myShapefileTable)

        myFeatureLayer.ID = "States"

        myFeatureLayer.DisplayName = "States"

 

        ' Add the FeatureLayer to the Map.

        MapView1.Map.Layers.Add(myFeatureLayer)

 

    End Sub

End Class

Outcomes