Select to view content in your preferred language

Feature layer

2658
12
07-01-2010 09:46 AM
TonyAlmeida
Frequent Contributor
I am new to Silverlight so please bare with me. I am testing the samples and they are excellent but when i try to in corporate my data i can't seem to get it to work. I am using the sample "Simple" under feature layer because i have some ArcGIS map services. This is my current code, so any help would be great thanks. We currently have some layers in ArcGIS server map services and varified the url and Map layer IDs through ArcGIS Services Directory.

<UserControl x:Class="SilverlightApplication7.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    xmlns:esri="clr-namespace:ESRI.ArcGIS.Client;assembly=ESRI.ArcGIS.Client">

    <Grid x:Name="LayoutRoot" Background="Snow">
        <esri:Map x:Name="MyMap" Extent="-130,10,-70,60" >
            <esri:ArcGISTiledMapServiceLayer ID="StreetMapLayer"
                    Url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer"/>
            <esri:FeatureLayer ID="MyFeatureLayer"
                    Url="http://gis.c****n**.org/ArcGIS/rest/services/Internal/AGS_DSD/MapServer/0"/>
           
        </esri:Map>
                 
                 
    </Grid>
</UserControl>
0 Kudos
12 Replies
RobertBurke
Esri Contributor
Hi Tony,

Great to see that you are using the samples!

My first guess is that the spatial references of the two services are not compatible.

Can you give more information, like which version of the API are you using, what error messages or behavior are you seeing, and have you added any ArcGIS references to your project?

I have included some code below that I test ran using some Earthquakes as the feature layer. It seems to work fine.

Let us know what happens.

Thanks,
Rob Burke
ESRI-Instructor


<UserControl x:Class="fLayerTest.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    xmlns:esri="clr-namespace:ESRI.ArcGIS.Client;assembly=ESRI.ArcGIS.Client">
  

      <Grid x:Name="LayoutRoot" Background="White">
         
        <esri:Map x:Name="MyMap" Extent="-130,10,-70,60" >
        <esri:ArcGISTiledMapServiceLayer ID="StreetMapLayer"
Url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer"/>
           
            <esri:FeatureLayer ID="MyFeatureLayer"
Url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Earthquakes/Since_1970/MapServer/0"/>

        </esri:Map>


    </Grid>
</UserControl>
0 Kudos
dotMorten_esri
Esri Notable Contributor
You say you "cant seem to make it work", but what is not working? Don't you get any data? Do you get an error? Do you see the tiled map but not the featurelayer? etc... I'm a really poor guesser when it comes to errors 🙂

I suggest you take a look at what goes on (or goes wrong) under the covers using Fiddler. I discuss this in this blogpost: http://blogs.esri.com/Dev/blogs/silverlightwpf/archive/2009/08/24/Troubleshooting-blank-layers.aspx

Rob: Spatial Reference issues only applies to Tiled layers. Featurelayers automatically reproject themselves to the base map, so this should be a non-issue.
0 Kudos
TonyAlmeida
Frequent Contributor
SharpGIS i ran fiddler and it seems like i am getting a 404 on my server. So do i need a clientaccesspolicy.xml, so would the policy used by ESRI work for mine?

<access-policy>
�??
<cross-domain-access>
�??
<policy>
�??
<allow-from http-request-headers="*">
<domain uri="*"/>
<domain uri="http://*"/>
</allow-from>
�??
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
0 Kudos
dotMorten_esri
Esri Notable Contributor
Yes that should do the trick.
0 Kudos
TonyAlmeida
Frequent Contributor
Why would this code not work with Silverlight...

<UserControl x:Class="ArcGISSilverlightSDK.DynamicMap"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:esri="http://schemas.esri.com/arcgis/client/2009">
    <Grid x:Name="LayoutRoot" Background="White" >

        <esri:Map x:Name="MyMap" >
            <esri:ArcGISDynamicMapServiceLayer ID="11"
                Url="http://****.*******.org/ArcGIS/rest/services/Internal/AGS_General/MapServer" />
        </esri:Map>

    </Grid>



But with Flex it works fine with this code...

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
      xmlns:s="library://ns.adobe.com/flex/spark"
      xmlns:esri="http://www.esri.com/2008/ags"
      pageTitle="Example - ArcGIS API for Flex connecting to a dynamic AGS service">

<esri:Map>
  <esri:ArcGISDynamicMapServiceLayer url="http://***.******.org/ArcGIS/rest/services/Internal/AGS_General/MapServer"/>
</esri:Map>

</s:Application>

What gives?
0 Kudos
dotMorten_esri
Esri Notable Contributor
So what is not working now?
0 Kudos
TonyAlmeida
Frequent Contributor
When i run xaml i don't get 404 error with Fiddler. I am still getting a blank layer. Is the clientaccesspolicy.xm only need for Silverlight and not flex? reason i ask is because i can see the layers in Flex.
0 Kudos
dotMorten_esri
Esri Notable Contributor
Flex uses a crossdomain.xml file, which is basically the same (Silverlight also supports using this file, but prefers the clientaccesspolicy.xml file).
What are you getting a 404 on?
0 Kudos
TonyAlmeida
Frequent Contributor
I am not getting an error, a new window in firefox opens but nothing happens.
0 Kudos