ArcGISRuntimeSDKDotNet_DesktopSamples Error

4734
9
Jump to solution
06-30-2015 10:01 AM
JoseCorral1
New Contributor II

Good Morning,

I created my runtime content from ArcMap ( xxxx.geodatabase ). and try to create a desktop application that show my layers, but is look like the

ArcGISTiledMapServiceLayer is overlapping my layers and I cannot see them. When I comment the ArcGISTiledMapServiceLa, my layers are showing up. I am using the code that is in the sample that comes with ArcGIS Runtime for .NET and is not working either. Any help will be very apreciated.

Below is the code I am using: ( same from example: Feature Layer from Local Database in SRcGisRuntineSDKDotNet_DesktopSample )

<UserControl x:Class="ArcGISRuntimeSDKDotNet_DesktopSamples.Samples.FeatureLayerFromLocalGeodatabase"
     xmlns:esri="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

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

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

   <Grid>
       <esri:MapView x:Name="MyMapView" WrapAround="True"
            Loaded="MyMapView_Loaded"  >

       <esri:Map>

            <esri:ArcGISTiledMapServiceLayer DisplayName="Basemap"
                                   ServiceUri="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" />

            </esri:Map>

       </esri:MapView>
   </Grid>
<UserControl>

namespace ArcGISRuntimeSDKDotNet_DesktopSamples.Samples
{
    public partial class FeatureLayerFromLocalGeodatabase : UserControl
    {
        private const string GDB_PATH = @"C:\Data\Data.geodatabase";

        public FeatureLayerFromLocalGeodatabase()
        {
            InitializeComponent();
        }

private void MyMapView_Loaded(object sender, RoutedEventArgs e)
        {
            CreateFeatureLayers();
        }

        private async void CreateFeatureLayers()
        {
            try
            {
                var gdb = await Geodatabase.OpenAsync(GDB_PATH);

                Envelope extent = null;
                foreach (var table in gdb.FeatureTables)
                {
                    var flayer = new FeatureLayer()
                    {
                        ID = table.Name,
                        DisplayName = table.Name,
                        FeatureTable = table
                    };

                    if (!Geometry.IsNullOrEmpty(table.ServiceInfo.Extent))
                      {
                          if (Geometry.IsNullOrEmpty(extent))
                             extent = table.ServiceInfo.Extent;
                          else
                             extent = extent.Union(table.ServiceInfo.Extent);
                       }
        
                     MyMapView.Map.Layers.Add(flayer);
                }

               await MyMapView.SetViewAsync(extent.Expand(1.10));

            }
            catch (Exception ex)
            {
                MessageBox.Show("Error creating feature layer: " + ex.Message, "Samples");
            }
        }

    }

}

Thank you

JoseLuisCorral

0 Kudos
1 Solution

Accepted Solutions
JoseCorral1
New Contributor II

Hello Freddie,

Thank you for helping me with this issue: As you say my map service is using different spatial reference ( WKID: 102658 / 2236 ) and my tables are using WKID: 4269 ( GCS NAD83 ). I have to find out the way to set both in the same coordinate system. Thank you.

View solution in original post

0 Kudos
9 Replies
FreddieGibson
Regular Contributor II

The basemap is covering your layer because of the drawing order. You should render the basemap prior to your layer. What exactly is the error that you're getting? If you're getting and error loading your sqlite geodatabase can you upload it?

JoseCorral1
New Contributor II

Thank you for your help.

I am not getting any error loading my layers, the issue is that I don't see my layers bacause the basemap is overlaping or covering them. In the piece of code in my question, I am redering the basemap first and then in the event: MyMapView_Loaded(...) I loading my xxx.geodatabase to get my layers. This piece of code is exactly the same that ESRI distributed in the ArcGIS runtime for .NET sample code: ArcGisRuntimeSDKDotNet_DesktopSamples. Even using their data the layers don't show up. If I comment the xaml:

<esri:Map>

            <!--<esri:ArcGISTiledMapServiceLayer DisplayName="Basemap"
ServiceUri="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"

             />-->

            </esri:Map>

I can see my layers.

Thank you.

0 Kudos
FreddieGibson
Regular Contributor II

Could you upload a zip of your sample and geodatabase so that I can take a quick look at it?

0 Kudos
JoseCorral1
New Contributor II

Thank you for your answer. I have create a test project where I try to open a feacture layer after the basemap. How can I upload the zip file?

Thank you.

0 Kudos
FreddieGibson
Regular Contributor II

GeoNET should allow you to attach the code in a response if you use the advanced editor.

0 Kudos
JoseCorral1
New Contributor II

Thank you Fressie,

Could you download the zip file from here?

Thaks

ArcGISAppTest.zip

0 Kudos
FreddieGibson
Regular Contributor II

I don't believe I have access to the map service you're using in your code, so I'm going to make assumptions based on the what I've seen in the code. So far it appears that the spatial reference of your map is set to 4326 (i.e. WGS84), whereas the layer you're adding from your mobile geodatabase uses 4269 (i.e. GCS NAD83). As per the documentation, "Your tables in the geodatabase must be in the same spatial references as the map you are adding them to because on-the-fly reprojection of data from these tables is not supported." I believe that this is why you're unable to see the second layer you've added to the map. Could you check the REST endpoint of your service to verify its coordinate system?

Spatial References

https://developers.arcgis.com/net/desktop/guide/spatial-references.htm

2015-08-17_1750.png

0 Kudos
FreddieGibson
Regular Contributor II

Hi Jose,

I've written up a quick sample to show what I believe you're running into. An image of the results is shown below.

The image displays side by side maps within a Runtime for .NET application. The maps contain three layers.

1) ArcGIS Online Basemaps (left uses Web Mercator projection and right uses WGS84 projection)

2) FeatureLayer from Mobile Geodatabase (both use Web Mercator projection)

3) Graphics Layer

When you run the application you'll notice that the FeatureLayer (the green polygon minus the red outline) only fails to display in the map that has a different coordinate system than the table in the mobile geodatabase. This is what the documentation is stating is an expected behavior.

projection.png

JoseCorral1
New Contributor II

Hello Freddie,

Thank you for helping me with this issue: As you say my map service is using different spatial reference ( WKID: 102658 / 2236 ) and my tables are using WKID: 4269 ( GCS NAD83 ). I have to find out the way to set both in the same coordinate system. Thank you.

0 Kudos