Select to view content in your preferred language

How to use definitionexpression in <sublayer>?

2971
16
08-26-2011 12:34 PM
BenKane
Regular Contributor
How do I implement a definition query using definitionexpression in the sublayer tag?  I see that it's possible but I can't find anywhere any sample code or syntax for how to implement this.
Tags (2)
0 Kudos
16 Replies
BrianOevermann
Frequent Contributor
Jeremy,

I'm at a loss.  The only difference I noticed is that the map service you are using has your layer ID 2 as part of a group layer.  Admittedly this is a very thin hypothesis, but maybe there is a quirky sort of bug related to group layers and definition expressions?

Ben's example is not directly using a layer within a group layer, but his service contains group layers. Robert's example is using a service that has no group layers present.  My example also has no group layers present.  I'm not sure if there is any merit to the idea, and I don't have the time available to exhaustively test this, but maybe you do have the time?

As an exercise, I copy/pasted your code block into the v2.4 viewer I am upgrading to.  I did change the value from 'BIA' to 'FS' because I know that we have U.S. Forest Service lands in reasonable proximity to our city.  I kept zooming out and noted that there are other labels (part of the map service group layer) that indicate features that the definition expression is eliminating, so your code appears to be working correctly for me.  See the attached screen shot.  There goes the group layer bug theory! [maybe]

It probably goes without saying, but you are using this tag against API 2.4 and not an earlier version, correct?  Just trying to cover the possibilities...
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Jeremy,

   I have tested the map service your provided as well, and as Brian, I was able to get the layer definition to work.
0 Kudos
CharlesHarris
Emerging Contributor
Thanks guys...I did realize what the problem was late last night as I tested this further.  The application that we were testing this in is still 2.3.x.  We will be upgrading it to v. 2.4 during our next release cycle.  I tested it in a fresh 2.4 viewer last night and it worked fine.  Thanks for the help!

Jeremy
0 Kudos
BenKane
Regular Contributor
Oops, yeah I made the same mistake...I've upgraded to Flexviewer 2.4 and now my definitionexpression works.  Thanks Robert and Jeremy for your help.

Ben
0 Kudos
BrianKaplan
Frequent Contributor
Here's one that I cannot get to work..

<layer label="USGS National Hazard System 1" type="dynamic" visible="false" alpha="1.0"
      url="http://rmgsc.cr.usgs.gov/ArcGIS/rest/services/nhss_haz/MapServer">
      <sublayer id="5" popupconfig="popups/PopUp_USGS_NHSS_Wildfire.xml"/>
      <sublayer id="6" definitionexpression="ACTIVE='Y'"  popupconfig="popups/PopUp_USGS_NHSS_WildfirePerimeters.xml"  />
         </layer>


Adding this definitionexpression makes this whole layer not show up.  Does anyone see anything obvious. I'm using 2.4  thanks  Brian Kaplan
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Brian,

   I don't see anything wrong here and I have tested and verified the issue you are having. I sorry to say I have not found a resolution though.
0 Kudos
BrianKaplan
Frequent Contributor
Thanks for checking.  When I add the rest layer to ArcMap, the legend comes up with the polygon symbol and a Y.  The polygon represents multiple datarows. When I use the info buttom, I get all records with N and Y, so something may be funky with the data feed.  Brian
0 Kudos