Select to view content in your preferred language

Identify Problem

1921
4
Jump to solution
03-14-2013 04:19 AM
TolgaBakirman
Deactivated User
Hello,
I'm really new to ArcGIS for Silverlight.
I'm trying to create map that contains a base map, a polygon layer and a point layer. And i want to identify the point features.
I can see the layers. But whenever i click on the points, i get this error message:
[ATTACH=CONFIG]22594[/ATTACH]
Here is the mainpage.xaml:
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"     xmlns:esri="http://schemas.esri.com/arcgis/client/2009"     xmlns:slData="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"     xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"     mc:Ignorable="d"     d:DesignHeight="300" d:DesignWidth="400">      <Grid x:Name="LayoutRoot" Background="White" >          <Grid.Resources>             <esri:PictureMarkerSymbol x:Key="DefaultPictureSymbol" OffsetX="35" OffsetY="35"                   Source="/Assets/images/i_about.png" />             <esri:SimpleRenderer x:Key="MySimplePolygonRenderer">             <esri:SimpleRenderer.Symbol>                 <esri:SimpleFillSymbol Fill="Green">                 </esri:SimpleFillSymbol>             </esri:SimpleRenderer.Symbol>             </esri:SimpleRenderer>             <esri:SimpleRenderer x:Key="MySimplePolylineRenderer">                 <esri:SimpleRenderer.Symbol>                     <esri:SimpleLineSymbol Color="Red">                     </esri:SimpleLineSymbol>                 </esri:SimpleRenderer.Symbol>             </esri:SimpleRenderer>             <esri:SimpleRenderer x:Key="MySimpleMarker">                 <esri:SimpleRenderer.Symbol>                     <esri:SimpleMarkerSymbol Color="Red" Style="Circle"></esri:SimpleMarkerSymbol>                 </esri:SimpleRenderer.Symbol>              </esri:SimpleRenderer>         </Grid.Resources>          <esri:Map x:Name="MyMap" WrapAround="True" Background="White"                     Extent="406252.2726,4543357.5695,407437.2354,4544741.7271" MouseClick="QueryPoint_MouseClick" >             <esri:ArcGISDynamicMapServiceLayer ID="Uydu2011"                       Url="http://ibbmaps.ibb.gov.tr/maps/rest/services/Uydu_2011_ED50/MapServer"/>             <esri:FeatureLayer ID="Binalar"                       Url="http://services1.arcgis.com/woiXiLpMPLtJh7WJ/arcgis/rest/services/binalar/FeatureServer/0"                       Renderer="{StaticResource MySimplePolygonRenderer}"/>             <esri:FeatureLayer ID="Noktalar"                       Url="http://services1.arcgis.com/woiXiLpMPLtJh7WJ/arcgis/rest/services/noktalar/FeatureServer/0"                       Renderer="{StaticResource MySimpleMarker}"/> <esri:GraphicsLayer ID="MyGraphicsLayer" />         </esri:Map>         <Border x:Name="IdentifyBorder" Background="#77919191" BorderThickness="1" CornerRadius="5"                 HorizontalAlignment="Right" BorderBrush="Gray" VerticalAlignment="Top"                  Margin="5">             <Border.Effect>                 <DropShadowEffect/>             </Border.Effect>             <Grid x:Name="IdentifyGrid" HorizontalAlignment="Right" VerticalAlignment="Top" >                 <Grid.RowDefinitions>                     <RowDefinition Height="30" />                     <RowDefinition Height="*" />                 </Grid.RowDefinitions>                 <TextBlock x:Name="DataDisplayTitleBottom" Text="?lçe Sorgulamak ?çin Haritaya T?klay?n?z"                         Foreground="White" FontSize="10" Grid.Row="0"                                              Margin="15,5,15,1" HorizontalAlignment="Center" >                     <TextBlock.Effect>                         <DropShadowEffect />                                               </TextBlock.Effect>                 </TextBlock>                 <Grid x:Name="IdentifyResultsPanel" Margin="5,1,5,5" HorizontalAlignment="Center"                              VerticalAlignment="Top" Visibility="Collapsed" Grid.Row="1">                     <Grid.RowDefinitions>                         <RowDefinition Height="30" />                         <RowDefinition Height="*" />                     </Grid.RowDefinitions>                     <ComboBox x:Name="IdentifyComboBox" SelectionChanged="cb_SelectionChanged"                          Margin="5,1,5,5" Grid.Row="0">                     </ComboBox>                     <ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Auto"                            Width="230" MinHeight="200" Grid.Row="1">                         <slData:DataGrid x:Name="IdentifyDetailsDataGrid" AutoGenerateColumns="False" HeadersVisibility="None"                                Background="White">                             <slData:DataGrid.Columns>                                 <slData:DataGridTextColumn Binding="{Binding Path=Key}" FontWeight="Bold"/>                                 <slData:DataGridTextColumn Binding="{Binding Path=Value}"/>                             </slData:DataGrid.Columns>                         </slData:DataGrid>                     </ScrollViewer>                 </Grid>             </Grid>         </Border>          <Border Background="#77919191" BorderThickness="1" CornerRadius="5"             HorizontalAlignment="Left"  VerticalAlignment="Top"             Margin="20" Padding="5" BorderBrush="Black" >             <ListBox x:Name="MyList" ItemsSource="{Binding ElementName=MyMap, Path=Layers}">                 <ListBox.ItemTemplate>                     <DataTemplate>                         <StackPanel Orientation="Horizontal">                             <!--Layer visibility checkbox-->                             <CheckBox IsChecked="{Binding Visible, Mode=TwoWay}" />                             <!--Opacity slider-->                             <Slider Margin="-5,0,0,0" Minimum="0" Maximum="1" Width="30"                                  Value="{Binding Opacity, Mode=TwoWay}" Height="18" />                             <!--Layer name-->                             <TextBlock Text="{Binding ID, Mode=OneWay}" Margin="5,0,0,0" >                              <!-- Tooltip on hover-->                                 <ToolTipService.ToolTip>                                     <StackPanel MaxWidth="400">                                         <TextBlock FontWeight="Bold" Text="{Binding CopyrightText}" TextWrapping="Wrap" />                                         <TextBlock Text="{Binding Description}" TextWrapping="Wrap" />                                     </StackPanel>                                 </ToolTipService.ToolTip>                             </TextBlock>                         </StackPanel>                     </DataTemplate>                 </ListBox.ItemTemplate>             </ListBox>         </Border>     </Grid>  </UserControl>
0 Kudos
1 Solution

Accepted Solutions
DominiqueBroux
Esri Frequent Contributor
Identify is available on MapServer and ImageServer but not on  FeatureServer that doesn't support it.

As the features are loaded locally, we don't need to request the server to get infos about them. Instead you can use MapTips that work locally.
Samples:
  - http://resources.arcgis.com/en/help/silverlight-api/samples/start.htm#GraphicsMapTip
  - http://resources.arcgis.com/en/help/silverlight-api/samples/start.htm#MapTipWidget

View solution in original post

0 Kudos
4 Replies
TolgaBakirman
Deactivated User
Here is the mainpage.xaml.cs :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using ESRI.ArcGIS.Client;
using ESRI.ArcGIS.Client.Tasks;

namespace SilverlightApplication11
{
    public partial class MainPage : UserControl
    {
         private List<DataItem> _dataItems = null;

        public MainPage()
        {
            InitializeComponent();
        }

        private void QueryPoint_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
        {
            ESRI.ArcGIS.Client.Geometry.MapPoint clickPoint = e.MapPoint;

            ESRI.ArcGIS.Client.Tasks.IdentifyParameters identifyParams = new IdentifyParameters()
            {
                Geometry = clickPoint,
                MapExtent = MyMap.Extent,
                Width = (int)MyMap.ActualWidth,
                Height = (int)MyMap.ActualHeight,
                LayerOption = LayerOption.visible,
                SpatialReference = MyMap.SpatialReference
            };

            IdentifyTask identifyTask = new IdentifyTask("http://services1.arcgis.com/woiXiLpMPLtJh7WJ/arcgis/rest/services/noktalar/FeatureServer");
            identifyTask.ExecuteCompleted += IdentifyTask_ExecuteCompleted;
            identifyTask.Failed += IdentifyTask_Failed;
            identifyTask.ExecuteAsync(identifyParams);

            GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
            graphicsLayer.ClearGraphics();
            ESRI.ArcGIS.Client.Graphic graphic = new ESRI.ArcGIS.Client.Graphic()
            {
                Geometry = clickPoint,
                Symbol = LayoutRoot.Resources["DefaultPictureSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol
            };
            graphicsLayer.Graphics.Add(graphic);
        }

        public void ShowFeatures(List<IdentifyResult> results)
        {
            _dataItems = new List<DataItem>();

            if (results != null && results.Count > 0)
            {
                IdentifyComboBox.Items.Clear();
                foreach (IdentifyResult result in results)
                {
                    Graphic feature = result.Feature;
                    string title = result.Value.ToString() + " (" + result.LayerName + ")";
                    _dataItems.Add(new DataItem()
                    {
                        Title = title,
                        Data = feature.Attributes
                    });
                    IdentifyComboBox.Items.Add(title);
                }
                IdentifyComboBox.SelectedIndex = 0;
            }
        }

        void cb_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            int index = IdentifyComboBox.SelectedIndex;
            if (index > -1)
                IdentifyDetailsDataGrid.ItemsSource = _dataItems[index].Data;
        }

        private void IdentifyTask_ExecuteCompleted(object sender, IdentifyEventArgs args)
        {
            IdentifyDetailsDataGrid.ItemsSource = null;

            if (args.IdentifyResults != null && args.IdentifyResults.Count > 0)
            {
                IdentifyResultsPanel.Visibility = Visibility.Visible;

                ShowFeatures(args.IdentifyResults);
            }
            else
            {
                IdentifyComboBox.Items.Clear();
                IdentifyComboBox.UpdateLayout();

                IdentifyResultsPanel.Visibility = Visibility.Collapsed;
            }
        }

        public class DataItem
        {
            public string Title { get; set; }
            public IDictionary<string, object> Data { get; set; }
        }

        void IdentifyTask_Failed(object sender, TaskFailedEventArgs e)
        {
            MessageBox.Show("Identify failed. Error: " + e.Error);
        }

    }
}


Thanks,

Tolga
0 Kudos
JohanCarlsson
Regular Contributor
You haven't specified a layerId in your Url. Try querying
http://services1.arcgis.com/woiXiLpMPLtJh7WJ/ArcGIS/rest/services/noktalar/FeatureServer/0
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Identify is available on MapServer and ImageServer but not on  FeatureServer that doesn't support it.

As the features are loaded locally, we don't need to request the server to get infos about them. Instead you can use MapTips that work locally.
Samples:
  - http://resources.arcgis.com/en/help/silverlight-api/samples/start.htm#GraphicsMapTip
  - http://resources.arcgis.com/en/help/silverlight-api/samples/start.htm#MapTipWidget
0 Kudos
TolgaBakirman
Deactivated User
Thanks,

Using MapServer solved my problem.

Regards,
0 Kudos