Select to view content in your preferred language

Some MapService Layers Query results won't display as graphics layers

4300
15
Jump to solution
03-28-2012 04:15 AM
MattMiley
Deactivated User
I'm using the find example and when i query my storm map service everything works. WHen i query my water map services i get results in the datagrid but they won't show up as graphics layers when i select them.

Here is the returned Json for Storm (WORKING)

{   "results" : [     {       "layerId" : 0,        "layerName" : "GIS.GISADMIN.StormNodes",        "displayFieldName" : "NodeType",        "foundFieldName" : "OBJECTID",        "value" : "11",        "attributes" : {         "OBJECTID" : "11",          "Element_ID" : "0",          "SOURCE_DES" : "Sanitary Sewer Improvements Contract 10-S",          "Coordinate" : "648444.115, 2060333.176",          "Shape" : "Point"       },        "geometryType" : "esriGeometryPoint",        "geometry" :        {         "x" : -9146569.69071188,          "y" : 5078354.76733345,          "spatialReference" : {           "wkid" : 102100         }       }     },      {       "layerId" : 2,        "layerName" : "GIS.GISADMIN.OutFalls",        "displayFieldName" : "StreamName",        "foundFieldName" : "OBJECTID",        "value" : "11",        "attributes" : {         "OBJECTID" : "11",          "StreamName" : "Black River",          "OutFallName" : "Tacoma",          "Shape" : "Point",          "Type" : "Outfall",          "Name" : "Null",          "Notes" : "Null",          "Notes_1" : "Null",          "Oberservation_Date" : "Null",          "Oberserver" : "Null"       },        "geometryType" : "esriGeometryPoint",        "geometry" :        {         "x" : -9140394.26845358,          "y" : 5078269.86245744,          "spatialReference" : {           "wkid" : 102100         }       }     }   ] }


Here is the returned Json for Water (NOT WORKING)

{   "results" : [     {       "layerId" : 0,        "layerName" : "Hydrants",        "displayFieldName" : "HYDRANTNUMBER",        "foundFieldName" : "OBJECTID",        "value" : "11",        "attributes" : {         "OBJECTID" : "11",          "HydrantNumber" : "H0561",          "Location" : "S.W. CORNER OF BROWNELL AVE.AND WEST ERIE AVE",          "Hyd_Num" : "Null"       },        "geometryType" : "esriGeometryPoint",        "geometry" :        {         "x" : -9149034.62292915,          "y" : 5081286.44737778,          "spatialReference" : {           "wkid" : 102100         }       }     },      {       "layerId" : 1,        "layerName" : "Valves",        "displayFieldName" : "VALVENUMBER",        "foundFieldName" : "OBJECTID",        "value" : "11",        "attributes" : {         "OBJECTID" : "11",          "ValveNumber" : "V4016",          "Valve_Diameter" : "8"       },        "geometryType" : "esriGeometryPoint",        "geometry" :        {         "x" : -9153324.01843533,          "y" : 5077188.05044879,          "spatialReference" : {           "wkid" : 102100         }       }     },      {       "layerId" : 2,        "layerName" : "LateralNodes",        "displayFieldName" : "ENABLED",        "foundFieldName" : "OBJECTID",        "value" : "11",        "attributes" : {         "OBJECTID" : "11",          "Enabled" : "True",          "SHAPE" : "Point"       },        "geometryType" : "esriGeometryPoint",        "geometry" :        {         "x" : -9159684.58115913,          "y" : 5072989.92068145,          "spatialReference" : {           "wkid" : 102100         }       }     }   ] }


Here is a storm layer attribute

Layer: GIS.GISADMIN.StormNodes (ID: 0) Display Field: NodeType  Type: Feature Layer  Geometry Type: esriGeometryPoint  Description:  Definition Expression:  Copyright Text:  Min. Scale: 10000  Max. Scale: 0  Default Visibility: True  Extent:      XMin: 2051575.44395877     YMin: 644699.275933608     XMax: 2071690.73607719     YMax: 657055.237114027     Spatial Reference: 3734  Has Attachments: False  HTML Popup Type: esriServerHTMLPopupTypeAsHTMLText  Drawing Info:      Renderer:         Unique Value Renderer:          Field 1: NodeType         Field 2:         Field 3:         Field Delimiter: ,         Default Symbol:             Unsupported Symbol         Default Label:         Unique Value Infos:             Value: Gutter Inlet             Label: Gutter Inlet             Description:             Symbol:                 Picture Marker Symbol:              Value: Inlet Basin             Label: Inlet Basin             Description:             Symbol:                 Picture Marker Symbol:              Value: Manhole             Label: Manhole             Description:             Symbol:                 Picture Marker Symbol:      Transparency: 0     Labeling Info: N/A  Fields:      OBJECTID (Type: esriFieldTypeOID, Alias: OBJECTID)     Element_ID (Type: esriFieldTypeDouble, Alias: Element_ID)     NodeType (Type: esriFieldTypeString, Alias: NodeType, Length: 32 )     NodeNumber (Type: esriFieldTypeString, Alias: NodeNumber, Length: 32 )     Coordinate (Type: esriFieldTypeString, Alias: Coordinate, Length: 30 )     Shape (Type: esriFieldTypeGeometry, Alias: Shape)  Type ID Field: N/A  Supported Interfaces:   REST  Supported Operations:   Query


Here is a water layer attributes, I think something is messed up here

Layer: Hydrants (ID: 0) Display Field: HYDRANTNUMBER  Type: Feature Layer  Geometry Type: esriGeometryPoint  Description:  Definition Expression:  Copyright Text:  Min. Scale: 10000  Max. Scale: 0  Default Visibility: True  Extent:      XMin: 2028056.97998909     YMin: 628506.51000617     XMax: 2077442.1400012     YMax: 662339.880002109     Spatial Reference: 3734  Has Attachments: False  HTML Popup Type: esriServerHTMLPopupTypeNone  Drawing Info:      Renderer:         Unique Value Renderer:          Field 1: Enabled         Field 2:         Field 3:         Field Delimiter: ,         Default Symbol:             Unsupported Symbol         Default Label:         Unique Value Infos:             Value: 0             Label: False             Description:             Symbol:                 Picture Marker Symbol:              Value: 1             Label: True             Description:             Symbol:                 Picture Marker Symbol:      Transparency: 0     Labeling Info:         Label Placement: esriServerPointLabelPlacementBelowCenter         Label Expression: [HYDRANTNUMBER]         Use Coded Values: True         Symbol:             Simple Text Symbol:             Type: esriTS             Color:255, 0, 0, 255             Background Color: null             Border Line Color: null             Vertical Alignment: bottom             Horizontal Alignment: center             Right To Left: False             Angle: 0             XOffset: 0             YOffset: 0             Font Family: Arial             Font Size: 8             Font Style: normal             Font Weight: bold             Font Decoration: none         Min. Scale: 0         Max. Scale: 0  Fields:      OBJECTID (Type: esriFieldTypeOID, Alias: OBJECTID)     HydrantNumber (Type: esriFieldTypeString, Alias: HydrantNumber, Length: 16 )     YearInstalled (Type: esriFieldTypeInteger, Alias: YearInstalled)     Manufacturer (Type: esriFieldTypeString, Alias: Manufacturer, Length: 32 )     Hyd_Num (Type: esriFieldTypeInteger, Alias: Hyd_Num)  Type ID Field: N/A  Supported Interfaces:   REST  Supported Operations:   Query 


What do you think is the problem here?
0 Kudos
15 Replies
DominiqueBroux
Esri Frequent Contributor
As it seems that your query is correct and returns one feature, my best bet is still that the rendering defined at the client side is not the right one.

Try by using a very simple renderer such as :
<esri:GraphicsLayer>
  <esri:GraphicsLayer.Renderer>
    <esri:SimpleRenderer>
      <esri:SimpleRenderer.Symbol><esri:SimpleMarkerSymbol Color="#99FF0000"/></esri:SimpleRenderer.Symbol>
    </esri:SimpleRenderer>
  </esri:GraphicsLayer.Renderer>
</esri:GraphicsLayer>
0 Kudos
DominiqueBroux
Esri Frequent Contributor
I think I found out the issue.

It's because your shape field is called SHAPE (uppercase) and the Find sample is looking for an attribute called "Shape".

switch (graphic.Attributes["Shape"].ToString()) .....


If you replace "SHAPE" by "Shape" that will work for your second service (but no more for the first one).

The test can be more generic:
if (graphic.Geometry is Polygon)     graphic.Symbol = LayoutRoot.Resources["DefaultFillSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol; else if (graphic.Geometry is Polyline)     graphic.Symbol = LayoutRoot.Resources["DefaultLineSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol; else if (graphic.Geometry is MapPoint)     graphic.Symbol = LayoutRoot.Resources["DefaultMarkerSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;

should work in both cases.
0 Kudos
MattMiley
Deactivated User
I think I found out the issue.

It's because your shape field is called SHAPE (uppercase) and the Find sample is looking for an attribute called "Shape".

switch (graphic.Attributes["Shape"].ToString()) .....


If you replace "SHAPE" by "Shape" that will work for your second service (but no more for the first one).



Thanks a bunch dbroux!
0 Kudos
MaciejGolebiewski
Emerging Contributor
Hello!
I think I'm encountering similar problem.
Am I doing something wrong or maybe there is some better practice to add results to graphics layer?
void QueryTaskArkPow_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.QueryEventArgs args4)
        {
            FeatureSet featureSet4 = args4.FeatureSet;

            if (featureSet4 != null && featureSet4.Features.Count > 0)
            {
                Query2DetailsDataGrid.ItemsSource = featureSet4.Features;
                featureSet4.SpatialReference = Map.SpatialReference;
                PowiatyButtonClear.IsEnabled = true;
                GraphicsLayer arkgmin = Map.Layers["ArkuszeLayer"] as GraphicsLayer;
                foreach (Graphic arkusz in featureSet4.Features)
                {
                    arkusz.Symbol = SelectedFeatureSymbol;
                    arkgmin.Graphics.Add(arkusz);
                }


            }


            else
                MessageBox.Show("No features returned from query");
        }


The query adds features' attributes to datagrid with no hesitation, I can also show messagebox for each feature with it's attributes or spatial reference, everything seems to be fine including the foreach loop.
What's even more odd it worked a couple days earlier, but now it just doesn't... 😞
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Two points to check:
   - is the geometry of the returned graphics OK? (don't forget to set the Query.ReturnGeometry flag to true, the ArcGIS server default value changed a little time ago, so that could explain your issue if your server was upgraded recently).
   - does your SelectedFeatureSymbol match the geometry type (point, line, polygon) of your graphics?
0 Kudos
MaciejGolebiewski
Emerging Contributor

   - is the geometry of the returned graphics OK?

How to check it?

   - does your SelectedFeatureSymbol match the geometry type (point, line, polygon) of your graphics?


My symbols looks like so:
<Grid.Resources>
                       
                        <esriSymbols:SimpleMarkerSymbol x:Name="IdentifyLocationSymbol" Color="Blue" Size="5" />
                        <esri:SimpleFillSymbol x:Name="SelectedFeatureSymbol" Fill="#64FF0000" BorderBrush="Red" BorderThickness="2" />
                        <esri:SimpleFillSymbol x:Name="FindFillSymbol" Fill="#500000FF" BorderBrush="Blue" BorderThickness="1" />
                        
                    </Grid.Resources>

I use "SelectedFetureSymbol" also in an IdentifyTask and it renders fine...

EDIT:
My featureSet geometry type is Envelope. Is it wrong?
The Geometry of returned Graphic is null, why is it so?
ReturnGeometry is set to true.
Print screens attached.

EDIT2:
OK, the third thing to check was if "Shape" field is ticked in mxd, why this wasn't metioned in help?
0 Kudos