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

2947
25
Jump to solution
05-10-2018 10:04 AM
deleted-user-3QvhwBivZdaR
New Contributor III

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
New Contributor III

I saw a similar example in ArcGIS's JS sample page...for one, this sample is adding the parameters before the service is added to the map.  Also (and more significantly, I think), I am rendering the symbols on the fly  by changing the attribute used to define the symbology, as I said in my question.  I assign the renderer to a LayerDrawingOptions object, then pass those options to the layer with setLayerDrawingOptions.

I can see the effect of the layer definition visually, but the points are still there, just not visible.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Jason,

  Since your workflow is not a standard workflow and you have yet to share any relevant code I am not sure I can help you.

0 Kudos
deleted-user-3QvhwBivZdaR
New Contributor III

my  code is based on these examples from ArcGIS: this and this.  My code base is rather large and hard to give a sample that will encompass everything , but I can try.  The basic workflow is:

1) add dynamic map services

2) let user choose an attribute from layer

3) unique symbols based on attribute value are passed to UniqueValueRenderer, which is then assigned as renderer property to a LayerDrawingOptions object

4) drawing options assigned to layer visa setLayerDrawingOptions, then layer made visible with setVisibleLayers

for the dynamic map services to be able to render symbols, 'allow modification ...' checkbox in ArcGIS Server Manager is enabled for those layers.

0 Kudos
deleted-user-3QvhwBivZdaR
New Contributor III

HI Robert, I added a link to a demo and the relevant code snippet below:

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Jason,

   Your sample really helped. I did not know you where using the IdentifyTask and not just a simple InfoTemplate or PopupTemplate.

You need to apply the SQL definition to the IdentifyParamaters (lines 5 and 6).

      // identify task
      function executeIdentifyTask(event) {
        identifyParams.geometry = event.mapPoint;
        identifyParams.mapExtent = map.extent;
        identifyParams.layerDefinitions = [];
        identifyParams.layerDefinitions[0] = attributeField + '>0';
deleted-user-3QvhwBivZdaR
New Contributor III

thanks--so far, adding this code has resulted only in 'No information Available' return for clicking on any point, for any of the chosen attributes.  Did you add any other edits?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Jason,

   Nope. I am not seeing that on my end. Did you add both lines 5 and 6?

0 Kudos
deleted-user-3QvhwBivZdaR
New Contributor III

yes.   i tried a few variations (removing the other lines in the identify parameters, for instance) but not effect.  Here is the updated live demo..Here I only added your two new lines to the existing Identify Parameters:

Change attribute used for a renderer 

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Jason,

   you added those lines, but in the wrong place. Notice I show the function you should add those line to.

function executeIdentifyTask(event) {
0 Kudos
deleted-user-3QvhwBivZdaR
New Contributor III

ah yes you're right, works now, thanks! I will have to add more so as to get the current layer and attribute value in my actual code but I can do that without too much trouble I think.

0 Kudos