Select to view content in your preferred language

Graphics layer renderer

2852
7
06-12-2012 06:28 AM
RaoBase
Deactivated User
Hi, I am doing a query and would like to display the results using the same symbology as the layer's symbology in the service. I am using simple ESRI optimized symbols.
I would like to assign the UniqueValuerenderer to the graphics layer as below, but no symbol appears on the map. When I use a SimpleMarkerSymbol, these appear fine.
Am I missing something here?

var myLayer:ArcGISDynamicMapServiceLayer;

for each (var layer:Layer in map.layers)
{
if(layer is ArcGISDynamicMapServiceLayer && layer.name== "Test Data")
{
  myLayer = layer as ArcGISDynamicMapServiceLayer; 
}
}

ArcGISDynamicMapServiceLayer(myLayer).getDetails(0, new AsyncResponder(
function myResultFunction(result:LayerDetails, token:Object = null):void
{
  if(result.drawingInfo.renderer is com.esri.ags.renderers.UniqueValueRenderer)
  {
   graphicsLayer.renderer = result.drawingInfo.renderer as UniqueValueRenderer;  
  }
},
function myFaultFunction(error:Object, token:Object = null):void
{
  showMessage(error.toString(),false);
             }
Tags (2)
0 Kudos
7 Replies
DasaPaddock
Esri Regular Contributor
What is the query's "outFields" set to?
0 Kudos
RaoBase
Deactivated User
The query's "outFields" is set to a list of 3 fields, including the one used for creating Unique Values symbology in the mxd file.
This particular field has datatype Number and can have values 0,1 and 2.

Even setting queryLayer.outFields = [ "*" ]; does not work.



Any ideas??
0 Kudos
DasaPaddock
Esri Regular Contributor
What is the contents of "http://server/.../MapServer/[layer id]?f=pjson

Does it work fine if you use a FeatureLayer?
0 Kudos
RaoBase
Deactivated User
Using FeatureLayer doesn't work either.
var uv:UniqueValueRenderer = queryLayer.layerDetails.drawingInfo.renderer as UniqueValueRenderer;
graphicsLayer.renderer = uv;

The contents of "http://server/.../MapServer/[layer id]?f=pjson
is:
 

{
  "currentVersion" : 10.02,
  "id" : 0,
  "name" : "Incidents",
  "type" : "Feature Layer",
  "description" : "",
  "definitionExpression" : "",
  "geometryType" : "esriGeometryPoint",
  "copyrightText" : "",
  "parentLayer" : null,
  "subLayers" : [],
  "minScale" : 0,
  "maxScale" : 0,
  "defaultVisibility" : true,
  "extent" : {
    "xmin" : -3.25129999965429,
    "ymin" : 56.1690999995917,
    "xmax" : -2.24930000025779,
    "ymax" : 58.1633000001311,
    "spatialReference" : {
      "wkid" : 4277
    }
  },
  "hasAttachments" : false,
  "htmlPopupType" : "esriServerHTMLPopupTypeAsHTMLText",
  "drawingInfo" : {"renderer" :
    {
      "type" : "uniqueValue",
      "field1" : "CATEGORY",
      "field2" : null,
      "field3" : null,
      "fieldDelimiter" : ", ",
      "defaultSymbol" : null,
      "defaultLabel" : "\u003call other values\u003e",
      "uniqueValueInfos" : [
        {
          "value" : "0",
          "label" : "Slight",
          "description" : "",
          "symbol" :
          {
            "type" : "esriPMS",
            "url" : "29D26027",
            "imageData" : "iVBORw0KGgoAAAANSUhEUgAAAAsAAAALCAYAAACprHcmAAAAAXNSR0IB2cksfwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAANRJREFUGJWVzz1KxGAQxvHfGwIBbW0E8WMLS29gZaXyFmolNlvY7AE8gjZ2FsIeYMWtgwew9BgWxgj2EpXEYneNC0bwgSmG+c8zz6T+ofRnEwuHddBPWMOTxihfdiNo5uBYuBYMknZ3S7AbS/t540TQpBCfHWHQcf04lu5zhjPn07+yJpP5DM56VJ1wTa/N3FQvgs1u76ykmsB1ME7Y7mSbavztfFcZxswBdn5BHxZrl22MdZ8br/YeP5zV9LGKopaNFlQXtyveWhhXS95xPq2p5p/+Apl6N1KFu/HFAAAAAElFTkSuQmCC",
            "contentType" : "image/png",
            "color" : null,
            "width" : 8,
            "height" : 8,
            "angle" : 0,
            "xoffset" : 0,
            "yoffset" : 0
          }
        },
        {
          "value" : "1",
          "label" : "Serious",
          "description" : "",
          "symbol" :
          {
            "type" : "esriPMS",
            "url" : "FA94EED4",
            "imageData" : "iVBORw0KGgoAAAANSUhEUgAAAAsAAAALCAYAAACprHcmAAAAAXNSR0IB2cksfwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAM9JREFUGJWVzjFKxGAQxfH/QCA5hcIWlt7ASqZQk4Baic0W23gAj6CNvZADrLBtvq9LZelBFD2BiUiezRo+YXXxwRQz/AZexj+SpUvbtmdmNgd2gWdJy7quHwD9wCGEe+Aq+d03s6MY40lZlpeAMoAY47mkFE6RdBFCeKyqqsnWh8WWugug+a4x24Jnaec3YO8P/DphM1tJOvhNSlpNOM/zZhiGU0mHG+zTOI53E3b3z67rjvu+vwbmwI6kFzNbFkVx6+7vaWfc/QO4Wc/GfAGTBUtp13zhgAAAAABJRU5ErkJggg==",
            "contentType" : "image/png",
            "color" : null,
            "width" : 8,
            "height" : 8,
            "angle" : 0,
            "xoffset" : 0,
            "yoffset" : 0
          }
        },
        {
          "value" : "2",
          "label" : "Undefined",
          "description" : "",
          "symbol" :
          {
            "type" : "esriPMS",
            "url" : "BB2574B4",
            "imageData" : "iVBORw0KGgoAAAANSUhEUgAAAAsAAAALCAYAAACprHcmAAAAAXNSR0IB2cksfwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAALRJREFUGJWV0DFOQlEQheHvJi+5u8CEwpIdWFmplVgRGgoaFuASsLE3YQGYsAxKFqLRFZAhhGsBvPcwonGSKSb555wzU/lHVe2h0McIF3jDHK+JcgLveMGktdvDTeGuMEyU6qD48A2sKzHAErOj8viPuOMGzrkr4je422SO+MTlWTTnDxH1gQtcnYUjFo0yM9zj+gd0hecaTmwLt3i0/3MH7yXneYp4SqzbyhIbTA99tD+x+AIicyt91vk+1wAAAABJRU5ErkJggg==",
            "contentType" : "image/png",
            "color" : null,
            "width" : 8,
            "height" : 8,
            "angle" : 0,
            "xoffset" : 0,
            "yoffset" : 0
          }
        }
      ]
    },
    "transparency" : 0,
    "labelingInfo" : null},
  "displayField" : "NAME",
  "fields" : [
    {
      "name" : "objectid",
      "type" : "esriFieldTypeOID",
      "alias" : "objectid"},
    {
      "name" : "INCIDENTID",
      "type" : "esriFieldTypeString",
      "alias" : "INCIDENTID",
      "length" : 50},
    {
      "name" : "INCIDENTDATE",
      "type" : "esriFieldTypeDate",
      "alias" : "INCIDENTDATE",
      "length" : 36},
    {
      "name" : "LONGITUDE",
      "type" : "esriFieldTypeDouble",
      "alias" : "LONGITUDE"},
    {
      "name" : "LATITUDE",
      "type" : "esriFieldTypeDouble",
      "alias" : "LATITUDE"},
    {
      "name" : "ERROR",
      "type" : "esriFieldTypeInteger",
      "alias" : "ERROR"},
    {
      "name" : "SPEED",
      "type" : "esriFieldTypeInteger",
      "alias" : "SPEED"},
    {
      "name" : "DIRECTION",
      "type" : "esriFieldTypeInteger",
      "alias" : "DIRECTION"},
    {
      "name" : "shape",
      "type" : "esriFieldTypeGeometry",
      "alias" : "shape"},
    {
      "name" : "CATEGORY",
      "type" : "esriFieldTypeDouble",
      "alias" : "CATEGORY"},

  ],
  "typeIdField" : null,
  "types" : null,
  "relationships" : [],
  "capabilities" : "Map,Query,Data"
}
0 Kudos
DasaPaddock
Esri Regular Contributor
This JSON is invalid. There shouldn't be a comma on this line:
    "alias" : "CATEGORY"},

Was this just a copy/paste error?

See: http://jsonlint.com/
0 Kudos
RaoBase
Deactivated User
Yes, this was just a copy/paste mistake. Has anyone been able to successfully set the feature layer renderer to a graphics layer?
0 Kudos
DasaPaddock
Esri Regular Contributor
It looks like it should work.

Have you confirmed that the features have a value of 0, 1 or 2 for the CATEGORY field?

Have you tried just putting the FeatureLayer in the map?

Is this service publicly available?

Can you provide a complete test case?
0 Kudos