Are there known issues showing an ArcGISTiledMapServiceLayer and FeatureLayers from a GeodatabaseFeatureTable in the same map when they have different SpatialReferences?

5318
7
Jump to solution
10-17-2014 09:29 AM
MattRickard
New Contributor II

The ArcGISTiledMapServiceLayer is http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer

My FeatureLayers are GeodatabaseFeatureTables coming from a local geodatabase file.

The SpatialReference for the Service is 102100.

The SpatialReference for the geodatabase/FeatureLayers is 2285.

If I add just the FeatureLayers to the map, it looks fine.

If I add the Imagery Map Service and then my FeatureLayers, I see only the Satellite Imagery.  My FeatureLayers seem to load ok, but are not visible on the map.  At least there are no errors in my LayerLoaded handler.

If I force the code to load my feature layers first, so the Map has a spatial reference of 2285, then add the Image Service layer, I get the following error in my LayerLoaded handler.

"Layer cannot be displayed on a Map with a different spatial reference."

Any ideas how I can get these two data sources to play nice together?

0 Kudos
1 Solution

Accepted Solutions
dotMorten_esri
Esri Notable Contributor

Local Feature tables does NOT support projection on the fly. If your map is in a different spatial reference, the feature layers will not render. This is a known limitation. In other words your map server must be in the same projection as your feature data.

View solution in original post

0 Kudos
7 Replies
JenniferNery
Esri Regular Contributor

Hi Matt,

I am not aware of any known issue that will prevent map from displaying features with different SpatialReference. But unfortunately, I'm able to reproduce the issue.

I also tried the following. I'm not sure if you are working with ServiceFeatureTable or ArcGISFeatureTable. At any case, they both have RowCount and QueryAsync. In my repro sample, after the map loads, the table seems empty (no request for features was made - it should have). Performing query, returns features in the correct spatial reference, matching MapView.SpatialReference=3857 yet no features display.

        private async void Button_Click(object sender, RoutedEventArgs e)

        {

            string message = null;

            var layer = MyMapView.Map.Layers["MyLayer"] as FeatureLayer;

            try

            {

                var table = ((ServiceFeatureTable)layer.FeatureTable);

                if (!table.IsInitialized)

                {

                    await table.InitializeAsync();

                }

                if (table.RowCount <= 0)

                {

                    var features = await layer.FeatureTable.QueryAsync(new QueryFilter() { WhereClause = "1=1" });

                }

            }

            catch (Exception ex)

            {

                message = ex.Message;

            }

            if (!string.IsNullOrWhiteSpace(message))

                MessageBox.Show(message);

        }

I will create an issue for this. But could you try the same code and let me know whether table is intialized properly, have rows and if performing query display features for you?

Thanks.

Jennifer

0 Kudos
MattRickard
New Contributor II

I am using GeodatabaseFeatureTable from a runtime content "geodatabase" file on my local machine.

I plugged the following code into my test app.

The debug output is below.

I got features back from my query, but the map still had only the satellite imagery.

private async void ESRI_TESTBUTTONCLICK(object sender, RoutedEventArgs e)

{

    string message = null;

    foreach (var layer in esriMap.Layers.OfType<FeatureLayer>())

    {

        try

        {

            var table = ((GeodatabaseFeatureTable)layer.FeatureTable);

            var features = await layer.FeatureTable.QueryAsync(new QueryFilter() { WhereClause = "1=1" });

            var featureCount = features.Count();

            if (featureCount > 0)

            {

                Debug.WriteLine(string.Format("{0}: {1}",table.Name,featureCount));

            }           

        }

        catch (Exception ex)

        {

            message = ex.Message;

        }

        if (!string.IsNullOrWhiteSpace(message))

            MessageBox.Show(message);

    }

}

DEBUG OUTPUT:

Parcels: 14

Roads: 5

SecondaryLine: 30

Electric_Net_Junctions: 9

SpanGuy: 1

Riser: 4

Station: 45

0 Kudos
JenniferNery
Esri Regular Contributor

Actually, the service I was using had some scale dependency. And as soon as I zoomed in, the features showed up.

If you are also using a scale-dependent service, can you try the following?

- Load map without tiled layer (just the feature layer)

- Get the MapView.Extent.GetCenter() and use this as InitialViewPoint.

In my case, the service was visible at specific scale. You can check the service metadata

metadata.PNG

        <esri:MapView x:Name="MyMapView" >

            <esri:Map>

                <esri:Map.InitialViewpoint>

                    <esri:ViewpointCenter X="1109557.6630192"

                                          Y="598570.670764685"

                                          SpatialReferenceID="2285"

                                          Scale="48000"/>

                </esri:Map.InitialViewpoint>

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

                <esri:FeatureLayer ID="MyLayer">

                    <esri:ServiceFeatureTable Mode="Snapshot" ServiceUri="your service with SR=2285" />

                </esri:FeatureLayer>

This seems to work just fine so I don't think there is any projection or rendering issue as I initially thought.  Could you confirm if you still find issues?

Thanks.

0 Kudos
MattRickard
New Contributor II

My FeatureLayers are not coming from a service.  They are coming from a geodatabase file.

Geodatabase _gdb = await Geodatabase.OpenAsync(gdbFileName);

foreach (var t in _gdb.FeatureTables)

{

    esriMap.Layers.Add(new FeatureLayer(t) { DisplayName = t.Name });

}

I did what you suggested and set my InitialViewpoint in xaml to:

<esri:Map.InitialViewpoint>

           <esri:ViewpointCenter X="1959687" Y="555209" Scale="4205" SpatialReferenceID="2285"/>

</esri:Map.InitialViewpoint>

Then, when I tried to load the imagery and my feature layers, I got the following error in my LayerLoaded handler:

"Layer cannot be displayed on a Map with a different spatial reference."

0 Kudos
LukePatterson
New Contributor III

As I have also found out, some of the layer types don't reproject on the fly to the map's spatial reference. It seems that the ShapeFileTable layers, the Geodatabase layers (as your are using above), and the tiled layers (both ArcGisTiledMapServiceLayer and ArcGISLocalTiledLayer) fall into this category. The map will take on the spatial reference of the first layer added and any additional layers from a different spatial reference will need to be reprojectable. Since you have no control over the ArcGisTiledMapServiceLayer, I think the only way to have both layers working together in the map would be to convert your Geodatabase to the same spatial reference as the tiled service.

0 Kudos
dotMorten_esri
Esri Notable Contributor

Local Feature tables does NOT support projection on the fly. If your map is in a different spatial reference, the feature layers will not render. This is a known limitation. In other words your map server must be in the same projection as your feature data.

0 Kudos
SimonFisher
Occasional Contributor II

Is there anyway to check what the spatial reference is on an ArcGIS runtime geodatabase?  These cannot be reopened in ArcMap correct?  We have clients creating these and they are not showing up when combined with their own TPKs, so I suspect they are in different spatial references, but they claim they are the same SR as the TPKs.  The gdb's show fine on their own, so they are not clipped like suggested in another thread.

Thanks

Simon

0 Kudos