FeatureService with different spatialreference

1882
3
Jump to solution
06-15-2016 03:06 AM
RamiGhali2
New Contributor II

Hello,

In AppStudio, desktop edition, Is it possible to add FeatureService with a spatial reference different from the basemap's ? If yes, how can I do that ?

I tried the below QML but the featureservice doesn't show !

Map {

        id: mainMap

        anchors.fill: parent

        extent: envelopeInitalExtent

        wrapAroundEnabled: true

        rotationByPinchingEnabled: true

        magnifierOnPressAndHoldEnabled: false

        mapPanningByMagnifierEnabled: true

        zoomByPinchingEnabled: true

        //INITIAL EXTENT

        Envelope {

            id: envelopeInitalExtent

            xMax: -13630134.691272736

            yMax: 4554320.7069897875

            xMin: -13647294.804122735

            yMin: 4535211.44991852

            spatialReference: mainMap.spatialReference

        }

        //BASEMAP

        ArcGISTiledMapServiceLayer {

            url: appWindow.info.propertyValue("basemapServiceUrl", "http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer")

        }

        //CREATE A FEATURE SERVICE TABLE FROM A FEATURE SERVICE

        GeodatabaseFeatureServiceTable {

            id: featureServiceTable

            url: "MY_FS_URL"

            spatialReference: mainMap.spatialReference

        }

        FeatureLayer {

            id: featureLayer

            featureTable: featureServiceTable

        }      

    }

Thanks.

0 Kudos
1 Solution

Accepted Solutions
LucasDanzinger
Esri Frequent Contributor

Yes, this should work. A couple of key points:

  1. The map takes on the spatial reference of the first layer added, so if you first add a tiled map service layer that is in WKID 102100, that is what your Map will now be in (just like how the data frame in ArcMap behaves)
  2. If you add in a FeatureLayer pointing to a Feature Service, it'll automatically request features be returned in the spatial reference of the map. So if your first layer is in 102100, and you add a feature layer pointing to a feature service in 4326, it'll request the features be returned from the server in 102100, and should then display on the map
  3. There is no need to set the spatial reference of the feature table like you are doing in the above code. The layer will figure out what the map's spatial reference is, and automatically request features to be returned in that spatial reference.

- Luke

View solution in original post

3 Replies
LucasDanzinger
Esri Frequent Contributor

Yes, this should work. A couple of key points:

  1. The map takes on the spatial reference of the first layer added, so if you first add a tiled map service layer that is in WKID 102100, that is what your Map will now be in (just like how the data frame in ArcMap behaves)
  2. If you add in a FeatureLayer pointing to a Feature Service, it'll automatically request features be returned in the spatial reference of the map. So if your first layer is in 102100, and you add a feature layer pointing to a feature service in 4326, it'll request the features be returned from the server in 102100, and should then display on the map
  3. There is no need to set the spatial reference of the feature table like you are doing in the above code. The layer will figure out what the map's spatial reference is, and automatically request features to be returned in that spatial reference.

- Luke

RamiGhali2
New Contributor II

Thank you Lucas for your reply.

What I found is that the FeatureService I'm trying to add is secured so, it needs authentication before being able to display it !

0 Kudos
nakulmanocha
Esri Regular Contributor

Yes it should work just fine unless you are adding a local (offline) geodatabase and in that case it should be in same spatial reference as the basemap. I tested the following code and works fine

ArcGISTiledMapServiceLayer {

            url: "http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"

        }

        GeodatabaseFeatureServiceTable {

            id: featureServiceTable

            url: "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Water_Network/FeatureServer/23"

        }

FeatureLayer {

            id: featureLayer

            featureTable: featureServiceTable

        }