FeatureLayer does not projected to spatial reference specified in XAML.

3174
9
04-15-2011 09:57 AM
by Anonymous User
Not applicable
Original User: huangs3

Hi GIS development experts:

    I am developing a Silverlight application to consum a Arcgis Server service (MapServer). The service contains feature layers.
   
    I specified the spatial reference with WKT in XAML code, but then the feature layer cannot be displayed. Following are the phenomenons I observed.
1. From the map server web page I can get a WKT for the spatial reference of the FeatureLayer (screenshot FeatureLayerSpatialReference.png);
2. If I specify exactly the same WKT as the web page in XAML for the map (screenshot XamlMapSpatialReference_Nodisplay.png), then the layer does not display;
3. If I spacify a spatial reference with empty WKT and WKID=0 in XAML, then the layer is displayed.

   I need to find out why this can happen... because in future I need to add a tiled basemap layer with the same spatial reference to the map, and at that time the XAML map spatial reference must be set with the WKT, either implicitly by the basemap or by explicitly XAML code.

   Can you give me some idea on any of the following?
1. why this can happen?
2. how to make the FeatureLayer work with the spatial reference?
3. is it because of the setup of ArcGIS server for the FeatureLayer? For example is the WKT in the web page really reflecting the spatial reference of the FeatureLayer?
4. is there any futher diagnosis to identify the reason?
5. how can I make this FeatureLayer work together with a tiled map, which has the same WKT? The tiled map cannot be re-projected, only the FeatureLayer can.

   Any other comments are welcome.
   Thank you!


My development environment:
-- .NET 4
-- C# and Visual Studio 2010
-- Silverlight 4
-- ESRI ArcGIS API for Microsoft Silverlight/WPF
-- ArcGIS server 9.31 map services
0 Kudos
9 Replies
SuiHuang
Occasional Contributor II
Hi Everybody:

    Here is a fact I noticed: the FeatureLayer I tried to add to the map is actually a sub-layer of a dynamic map service layer. If I add it into the map as a whole, then the spatial reference defined by WKT is handled properly and the layers are displayed, without needing me to explicitly specify the map spatial reference.
========================================================
<esri:ArcGISDynamicMapServiceLayer Url="http://*****/*****/rest/services/*****/*****/MapServer"/>
========================================================


   If I add only one of the sub-layers into the map like the following:
====================================================================
<esri:FeatureLayer Url="http://*****/*****/rest/services/*****/*****/MapServer/3"/>
====================================================================
then the issue described by the initial post of this thread will occur.

   Now I got a further question: I don't want to display all the sub-layers at once, is there anyway to add several sub-layers to the map individually, and still make their spatial references work?

   Thank you.
0 Kudos
by Anonymous User
Not applicable
Original User: chri6255

Hi,

In one of your attachments the xaml is wrong when declaring the WKT. You have to add a namespace so that you can declare a string in xaml.

Namespace
xmlns:sys="clr-namespace:System;assembly=mscorlib"


Xaml
<esri:Map>
            <esri:Map.Extent>
                <esri:Envelope XMin="" XMax="" YMin="" YMax="">
                    <esri:Envelope.SpatialReference>
                        <esri:SpatialReference WKID="0">
                            <esri:SpatialReference.WKT>
                                <sys:String>your custom projection goes between these tags</sys:String>
                            </esri:SpatialReference.WKT>
                        </esri:SpatialReference>
                    </esri:Envelope.SpatialReference>
                </esri:Envelope>
            </esri:Map.Extent>
        </esri:Map>        
0 Kudos
dotMorten_esri
Esri Notable Contributor
You cannot use WKT in a projection definition with a 9.x server (only WKID supported). You need at least v10.0 to support WKT
0 Kudos
by Anonymous User
Not applicable
Original User: huangs3

chri6255:

    Thank you for letting me know this.
    I changed the code but it still didn't work. Maybe this is because WKT does not work for ArcGIS Server 9.31 as SharpGIS said.

Hi,

In one of your attachments the xaml is wrong when declaring the WKT. You have to add a namespace so that you can declare a string in xaml.

Namespace
xmlns:sys="clr-namespace:System;assembly=mscorlib"


Xaml
<esri:Map>
            <esri:Map.Extent>
                <esri:Envelope XMin="" XMax="" YMin="" YMax="">
                    <esri:Envelope.SpatialReference>
                        <esri:SpatialReference WKID="0">
                            <esri:SpatialReference.WKT>
                                <sys:String>your custom projection goes between these tags</sys:String>
                            </esri:SpatialReference.WKT>
                        </esri:SpatialReference>
                    </esri:Envelope.SpatialReference>
                </esri:Envelope>
            </esri:Map.Extent>
        </esri:Map>        
0 Kudos
SuiHuang
Occasional Contributor II
Hi ShartGIS:

    Just to confirm, do you mean to fix this the map services must be changed to use WKID instead of WKT for ArcGIS Server 9.x?
    Thank you.

You cannot use WKT in a projection definition with a 9.x server (only WKID supported). You need at least v10.0 to support WKT
0 Kudos
SuiHuang
Occasional Contributor II
Hi SharpGIS:

     I found a map service from ESRI using WKT to define the spatial reference:

http://serverapps.esri.com/ArcGIS/rest/services/WashingtonDC/MapServer/2

     If they are correct then ArcGIS Server 9.31 supports WKT, isn't it?
     Thank you.

You cannot use WKT in a projection definition with a 9.x server (only WKID supported). You need at least v10.0 to support WKT
0 Kudos
by Anonymous User
Not applicable
Original User: chri6255

The problem is that services with WKT on a 9.31 are readonly. When you try to send data with WKT to a 9.31 service it does not know how to process the request. The ability to process WKT was added to version 10.0 of ArcGIS Server. So this service is really not useable for the Web API. If it is the routing you are after here is a 10.0 service that has routing.

http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/MapServer

but if you were just trying to figure out how to use WKT correctly then my previous post should work for you.

Here are some additional servers you can look at as well
http://sampleserver2.arcgisonline.com/ArcGIS/rest/services/Network/USA/MapServer
http://services.arcgisonline.com/ArcGIS/rest/services/Network/USA/MapServer

Hope this helps
0 Kudos
SuiHuang
Occasional Contributor II
Hi chri6255:

    I got a ArcGIS Server 10.01 map service setup, and the spatial reference works ok with it now.

    I found some further issues in my development with it: the features are displayed even if when the scale is beyond "Min. Scale", and not all the polygons get displayed when there are too many polygons in the layer.
    I may send some other discussion threads about the further issue.
    Thank you.

The problem is that services with WKT on a 9.31 are readonly. When you try to send data with WKT to a 9.31 service it does not know how to process the request. The ability to process WKT was added to version 10.0 of ArcGIS Server. So this service is really not useable for the Web API. If it is the routing you are after here is a 10.0 service that has routing.

http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/MapServer

but if you were just trying to figure out how to use WKT correctly then my previous post should work for you.

Here are some additional servers you can look at as well
http://sampleserver2.arcgisonline.com/ArcGIS/rest/services/Network/USA/MapServer
http://services.arcgisonline.com/ArcGIS/rest/services/Network/USA/MapServer

Hope this helps
0 Kudos
by Anonymous User
Not applicable
Original User: dbroux

I found some further issues in my development with it: the features are displayed even if when the scale is beyond "Min. Scale",

The minimum and maximum scales defined for a map service are automatically taken in care for the feature layers.
You have to set the minimum and maximum resolution of the feature layers by yourself.

and not all the polygons get displayed when there are too many polygons in the layer.

Likely you have reached the limit of how many features can be returned by one query (by default : 500 with AGS9.3.1, 10 with AGS 10.0).
The workaround may be either to use the 'OnDemand' mode that would load the features when zooming/panning (but still with the same limit for one query) or to change this limit by changing the configuration of the service (Service properties dialog box in ArcCatalog or Manager).
0 Kudos