Select to view content in your preferred language

(not) display rows with 0 value with Unique Value Renderer

4711
25
Jump to solution
05-10-2018 10:04 AM
deleted-user-3QvhwBivZdaR
Deactivated User

I am working on a web app using ArcGISDynamicMapServiceLayers, which use UniqueValueRenderers to draw points based on attributes.  In many cases, the attribute value is 0, in which cases I would not want to display anything.  If I do not assign some symbol to these values, the service draws the default symbol in those locations.  I tried assigning a symbol with 0 opacity (transparent), but when I use an InfoWindow in the web app, a click will still [pick up these invisible symbols.

Is there a way that I can not draw these symbols at all if the attribute value is 0?

The user will choose which attribute to use for rendering the symbols.  So that value may be 0 in some cases and nonzero in others. 

0 Kudos
25 Replies
deleted-user-3QvhwBivZdaR
Deactivated User

ps- I am still curious why the Image Parameters setting do not seem to remove the point from the layer (although it is invisible)...ideas?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Jason,

  Because you are using the IdentifyTask with the IdentifyParameter option LAYER_OPTION_ALL and it is not looking for what is visible on the map.

0 Kudos
deleted-user-3QvhwBivZdaR
Deactivated User

I can comment out that line and get the same results..My understanding was that the Image parameters setting should remove any zero value points from the layer entirely. (this is more for my own understanding)

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Jason,

   You understanding is correct for the layer in the map. But the IdentifyTask is going back to the server to do the identify operation and is not aware of the definition you applied to the layer in your map unless you specify it in the IdentifyParameters. If you were not using the IdentifyTask and just using a standard popup for the layer then it would work as you are expecting.

deleted-user-3QvhwBivZdaR
Deactivated User

got it, thanks for the explanation.

0 Kudos
deleted-user-3QvhwBivZdaR
Deactivated User

I created a simple demo of my problem here: (note that I can only keep this up for a short time)

Change attribute used for a renderer 

To demonstrate the problem I am having:

1) click on a point and see the info window, which will show the chosen attribute field and its value

2) remember where the current points are located, then, choose a different attribute from the dropdown window

3) now click on the same spot where a point no longer appears where it appeared earlier..you will see the current value of '0' in the info window

My goal is to remove these 'invisible' points entirely

Here is the code relevant to the renderer and the layer definitions:

var baseSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 15);
attributeField = document.getElementById("fieldNames").value; // these values correspond with attribute field names in layer
var renderer = new UniqueValueRenderer(baseSymbol, attributeField);

// the '0' value below makes the point invisible but does not remove point from the layer
renderer.addValue(0, new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 6).setColor(new Color([255, 0, 0,0]))); 
renderer.addValue(1, new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 6).setColor(new Color([255, 77, 77, 0.8])));
renderer.addValue(2, new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 8).setColor(new Color([230, 0, 0, 0.8])));

............................

var optionsArray = [];
var drawingOptions = new LayerDrawingOptions();
drawingOptions.renderer = renderer;
optionsArray[0] = drawingOptions;
var layerDefs = [];
layerDefs[0] = attributeField + '>0';
// layerDefs[0] = 'All_9_12>0'; // use hard coded attribute field as test to see if layerDefs are applied, commented out for now 
// imageParameters.layerDefinitions = layerDefs; // tried this an alternative method  // replace line below for image parameters // had no effect
map.getLayer("layer").setLayerDefinitions(layerDefs); // test line above confirmed that this is being implemented
map.getLayer("layer").setLayerDrawingOptions(optionsArray);
demoLayer.setVisibleLayers([0], true); 
map.getLayer("layer").show();

0 Kudos