Popups on multiple copies of same service layer

2326
11
Jump to solution
08-16-2012 11:02 AM
RhettZufelt
MVP Frequent Contributor
I have a service with three feature classes in it.  I load them with the follwing code: (As you can see, they are all from the same mapservice, just with different definitionexpression)

   <layer label="Post-closure" type="dynamic" visible="true" alpha="1"       url="http://gis01.wch-rcc.com/ArcGIS/rest/services/SDCV_custom/WCH_WIDS_Status/MapServer">       <sublayer id="3" popupconfig="popups/PopUp_wastepolys.xml" definitionexpression="LVL1Stage = 'Post-closure'"/>       <sublayer id="1" popupconfig="popups/PopUp_wastepoints.xml" definitionexpression="LVL1Stage = 'Post-closure'"/>       <sublayer id="2" popupconfig="popups/PopUp_wastelines.xml" definitionexpression="LVL1Stage = 'Post-closure'"/>     </layer>    <layer label="Closure" type="dynamic" visible="true" alpha="1"       url="http://gis01.wch-rcc.com/ArcGIS/rest/services/SDCV_custom/WCH_WIDS_Status/MapServer">       <sublayer id="3" popupconfig="popups/PopUp_wastepolys.xml" definitionexpression="LVL1Stage = 'Closure'"/>       <sublayer id="1" popupconfig="popups/PopUp_wastepoints.xml" definitionexpression="LVL1Stage = 'Closure'"/>       <sublayer id="2" popupconfig="popups/PopUp_wastelines.xml" definitionexpression="LVL1Stage = 'Closure'"/>       </layer>    <layer label="RTD" type="dynamic" visible="true" alpha="1"       url="http://gis01.wch-rcc.com/ArcGIS/rest/services/SDCV_custom/WCH_WIDS_Status/MapServer">       <sublayer id="3" popupconfig="popups/PopUp_wastepolys.xml" definitionexpression="LVL1Stage = 'RTD'"/>       <sublayer id="1" popupconfig="popups/PopUp_wastepoints.xml" definitionexpression="LVL1Stage = 'RTD'"/>       <sublayer id="2" popupconfig="popups/PopUp_wastelines.xml" definitionexpression="LVL1Stage = 'RTD'"/>     </layer>    <layer label="Confirmatory" type="dynamic" visible="true" alpha="1"       url="http://gis01.wch-rcc.com/ArcGIS/rest/services/SDCV_custom/WCH_WIDS_Status/MapServer">       <sublayer id="3" popupconfig="popups/PopUp_wastepolys.xml" definitionexpression="LVL1Stage = 'Confirmatory'"/>       <sublayer id="1" popupconfig="popups/PopUp_wastepoints.xml" definitionexpression="LVL1Stage = 'Confirmatory'"/>       <sublayer id="2" popupconfig="popups/PopUp_wastelines.xml" definitionexpression="LVL1Stage = 'Confirmatory'"/>     </layer>
This way, I can have it draw only a subset of each based on my definition and it loads a point, line, and polygon layer and displays features in all three that match the query that loads as a "single" layer.
The problem seems to be the popups only work on the last load instance of this layer.  I.e., with the above config, it will only popup on the "Post-closure" layer, and just ignores the "Closure" and other layers.  If I turn off the "Post-closure", then it will popup on the "Closure" layer.  I actually have to turn off "Post-closure" and "Closure" to get it to popup on "RTD" (see the pattern).  Since I have 4 different layers loaded from this same service, it will only popup one at a time and all the other layers "above" it need to be turned off.

Is it possible to make the popups work on "any" of the layers that are visible, regardless of which was turned on last or that they are from the same service?

R_
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RhettZufelt
MVP Frequent Contributor
Sounds like you issue is a little different.  My definition expressions are working normally, you just can't get popup information from the layers that are "underneath".

Solutions was to create a separate service for each one with the definitionexpression in ArcMap and not in the flexviewer.

It appears as if you are searching for County being less than AND greater than 'Brusnswick' with would be pretty much the same as <> 'Brunswick'

 definitionexpression="County &lt;&gt; 'Brunswick' AND County &lt;&gt; 'Bertie'"


This works:

 definitionexpression="County &gt; 'Bertie' AND County &lt; 'Brunswick'  "


And shows everything where County is between Bertie and Brunswick.

R_

View solution in original post

0 Kudos
11 Replies
AndrewEdmonds
New Contributor III
Rhett, did you ever find a solution for this problem?  I am running into the same issue.

I cannot get both of my two defintionexpression clauses to function properly simultaneously.  With the code below, only the second expression takes affect.

     <layer label="NC Surveyed Only" type="dynamic" visible="true" alpha="1.0"  
  url="http://gis.ncdcr.gov/ArcGIS/rest/services/NC_Surveyed_Only/MapServer">
  <sublayer id="0" popupconfig="popups/PopUp_Surveyed_NoPhoto.xml"   definitionexpression="County &lt;&gt; 'Brunswick' AND County &lt;&gt; 'Bertie'" />
  <sublayer id="0" popupconfig="popups/PopUp_Surveyed_Photo.xml"  definitionexpression="(County = 'Brunswick') OR (County = 'Bertie')" />
  <!-- sublayer id="0" popupconfig="popups/PopUp_Surveyed_Photo.xml" />  -->
     </layer>
0 Kudos
RhettZufelt
MVP Frequent Contributor
Sounds like you issue is a little different.  My definition expressions are working normally, you just can't get popup information from the layers that are "underneath".

Solutions was to create a separate service for each one with the definitionexpression in ArcMap and not in the flexviewer.

It appears as if you are searching for County being less than AND greater than 'Brusnswick' with would be pretty much the same as <> 'Brunswick'

 definitionexpression="County &lt;&gt; 'Brunswick' AND County &lt;&gt; 'Bertie'"


This works:

 definitionexpression="County &gt; 'Bertie' AND County &lt; 'Brunswick'  "


And shows everything where County is between Bertie and Brunswick.

R_
0 Kudos
AndrewEdmonds
New Contributor III
Yeah, I was hoping not to have to use two different services to accomplish this, since I don't want the TOC to show the layer twice.

I hoped I could just use flexviewer's definitionexpression on a binary field (ie, PhotoAvailable) to get two different pop-ups.  For the moment, County serves this purpose, as all points in a given county either have or do not have photos.
0 Kudos
RhettZufelt
MVP Frequent Contributor
a couple thoughts.  I have my popups set to not show the field if it is NULL or NoData.  If you are displaying other info as well, you could modify it this way, that way it would not show blank photo fields and would only populate them if data exists in the field.

Could copy the layer twice in ArcMap and put your two different expressions on each layer, group them and publish as a service.  If you load as type=dynamic, then you can assign a different popup.xml for each sublayer.

If you don't need the ability, you can disable the expand capability of the TOC so that it "looks" like one layer in the TOC with a single checkbox to turn on/off (don't know if you can disable the expand for a single layer).

Could also load the layer twice with different name and "hide" one of them from the TOC.  Of course, this method would not let you turn on/off the "hidden" layer without modifying the mxmls (something like if layer1 visible=false, then layer2 visible=false).

Just some thoughts,

R_
0 Kudos
AndrewEdmonds
New Contributor III
Thanks, Rhett, I appreciate it.  These are some good ideas and I'll incorporate one of them.

Still, sure seems like a workaround to what should be accomplished within the definitionexpression!
0 Kudos
RhettZufelt
MVP Frequent Contributor

I cannot get both of my two defintionexpression clauses to function properly simultaneously.  With the code below, only the second expression takes affect.

     <layer label="NC Surveyed Only" type="dynamic" visible="true" alpha="1.0"  
  url="http://gis.ncdcr.gov/ArcGIS/rest/services/NC_Surveyed_Only/MapServer">
  <sublayer id="0" popupconfig="popups/PopUp_Surveyed_NoPhoto.xml"   definitionexpression="County &lt;&gt; 'Brunswick' AND County &lt;&gt; 'Bertie'" />
  <sublayer id="0" popupconfig="popups/PopUp_Surveyed_Photo.xml"  definitionexpression="(County = 'Brunswick') OR (County = 'Bertie')" />
  <!-- sublayer id="0" popupconfig="popups/PopUp_Surveyed_Photo.xml" />  -->
     </layer>


I suspect that both are taking affect, it is just that the second one for id="0" is overwritting the first one as only one can be assigned to id="0".

I would suspect that to do this, you would have to link it to a custom popuprenderskin if it is possible.
One would have to look into if/how you can set the popupconfig.xml being used in the popuprenderskin.  If possible, then you could do an if/then statement to check for you criteria, and assign the proper xml.
This is where I put the coding to make the popup behave differently for different layers clicked on.  Though for mine, I have it add radio buttons IF I click on certain layers in the map so not sure about coding/access to the attribute data and ability to asign xml.

R_
0 Kudos
RhettZufelt
MVP Frequent Contributor
Andrew,

This post will show you how/where to evaluate the attribute info so you could test for county range, etc.

http://forums.arcgis.com/threads/67874-Popup-3.0-hide-field-if-value-null?highlight=popuprenderskin+...


Just need to figure out if there is then a way to set the popupconfig.xml used from within the popuprenderskin.

Not sure how the API works here.  Is the popupconfig.xml "assigned" before the popuprenderskin is fired or after? If before, maybe you can modify the list of fields, if after, maybe actually assign the desired.xml.   Not sure if it possible to set it, so hopefully someone will jump in with some info as to if this is possilbe, and give some ideas.

R_
0 Kudos
RhettZufelt
MVP Frequent Contributor
Andrew,

It appears as if the popupconfig.xml info is sent along on click to the popuprenderskin if you add one.

If you look at the link in my previous post, will give you an idea, then I have modified it like such:

   for each (var fieldInfo:PopUpFieldInfo in popUpInfo.popUpFieldInfos)
{
 if (fieldInfo.visible && (hostComponent.featureLayer.url == "http://gis01.wch-rcc.com/ArcGIS/rest/services/Base/Buildings2/MapServer/0" &&
     fieldInfo.fieldName == "TURNOVER_AREA") &&  (formattedAttributes[fieldInfo.fieldName] > "100-B/C" && formattedAttributes[fieldInfo.fieldName] < "100-K"))
      {
 break;
 }else if (fieldInfo.visible && formattedAttributes[fieldInfo.fieldName] && formattedAttributes[fieldInfo.fieldName] != " ")
 {
 var fieldLabel:Label = new Label();


So, if I click on a feature from my Buildings2/MapServer/0 AND the field name = "TURNOVER_AREA" AND the value of TURNOVER_AREA is between "100-B/C and 100-K", then the TURNOVER_AREA field/value will NOT be added to the popup infowindow.

The code in blue is what I added that does the evaluation.
The code in red keeps the field/values from being added if the value is NULL or blank. Delete this if you want to show "empty" fields as well.
The rest is existing code in the mxml.

Should be able to modify this to suit your needs,

R_

I see your service doesn't have attachments, so when you say that some counties don't have photos, does that mean that you have a field with photo names and/or urls in it, and some are blank/null? If so, the changes in red above will do exactly that. Well, almost, you will not see ANY fields (including photofield) on the infowindow if there isn't a value in it for that feature.
0 Kudos
RhettZufelt
MVP Frequent Contributor
Another thought, but I'm home now and won't be around FlashBuilder until Monday at earliest (possibly the following Monday) so cant test it out so I thought I'd throw it at ya in case you want to try.

You may be able to utilize the eSearchWidget for this.  Have not tried it, but you could try to enter the same layer in twice.  One with your expression that you want, the other would select everything <> to your expression.
You can then configure the popup fields for each config layer separately with their respective fields.
Have it preload=open and size it so it's just the "active" button (or whatever you want to see on the GUI).

Then disable everything except the graphic search (mappoint) button, and make active by default, and keep active.

Disable autozoom if you want it to behave more like a "regular" popup, otherwise, might actually be nice as the normal popup will "obscure" itself on the margins if the feature clicked is near the edge, and autozoom (or set the zoomscale so that it more auotpans) to feature option would be nice on the popup (In case the developers are reading this autopantocenter for popup feature option would be great 🙂.

Have not tried it, so don't know if you can do this with the "same" feature layer in the search.xml more than once, but it is pretty robust widget, so is worth a try.

Theory is that since the eSearch doesn't actually search the graphics loaded on the map, but rather the feature layer you list in the config, and, each layer has a <definitionexpression/>tag.  In "theory", if you click on a feature that doesn't match the definitionexpression, it should match the "other" layers query and pull the popup configed for that layer.  If it meets the criteria, the feature will be there and will show the popup fields configured for that layer.  This is why the two layers definitions queries would have to be mutually exclusive. (might even be able to do something like   defquery1 = sometest,   and defquiery2 = NOT(sometest) )

If you want to test, this is what I was thinking for the eSearchWidget.xml:

<?xml version="1.0" ?>
<!-- See Enhanced Search Widget XML Configuration.pdf for detailed explanation -->
<configuration>
 <layers>
  <layer>
   <definitionexpression>(County = 'Brunswick') OR (County = 'Bertie')</definitionexpression>
   <enableexport>false</enableexport>
   <name>NC Surveyed Only</name>
   <url>http://gis.ncdcr.gov/ArcGIS/rest/services/NC_Surveyed_Only/MapServer/0</url>
   <expressions/>

   <graphicalsearchlabel>Click for Info</graphicalsearchlabel>
   <spatialsearchlayer>false</spatialsearchlayer>
   <titlefield>Site_ID</titlefield>
   <fields all="false">
    <field name="Id" alias="Id" numberformat="2|,|." />
    <field name="Staus" alias="Staus" gridfield="false" />
    <field name="Site_Name" alias="Site_Name" gridfield="false" />
    <field name="Quad_Name" alias="Quad_Name" gridfield="false" />
    <field name="Notes" alias="Notes" gridfield="false" />
    <field name="DESCRIPTIO" alias="DESCRIPTIO" gridfield="false" />
    <field name="YearSurvey" alias="YearSurvey" gridfield="false" />
    <field name="YearUpdate" alias="YearUpdate" gridfield="false" />
    <field name="County" alias="County" gridfield="false" />
    <field name="Density" alias="Density" gridfield="false" />
    <field name="HDstatus" alias="HDstatus" gridfield="false" />
   </fields>
   <links/>
   <zoomscale usegeometry="true" zoompercent="1"></zoomscale>
   <autoopendatagrid>false</autoopendatagrid>
   <queryattachments>false</queryattachments>
   <relates/>
   <symbology>
    <simplefillsymbol color="0x0000ff" alpha="0.5">
     <outline color="0x00ffff" alpha="0.8" width="2" />
    </simplefillsymbol>
   </symbology>
  </layer>
  <layer>
   <definitionexpression>NOT((County = 'Brunswick') OR (County = 'Bertie'))</definitionexpression>
   <enableexport>false</enableexport>
   <name>NC Surveyed Only</name>
   <url>http://gis.ncdcr.gov/ArcGIS/rest/services/NC_Surveyed_Only/MapServer/0</url>
   <expressions/>

   <graphicalsearchlabel>Click for Info</graphicalsearchlabel>
   <spatialsearchlayer>false</spatialsearchlayer>
   <titlefield>Site_ID</titlefield>
   <fields all="false">
    <field name="Id" alias="Id" numberformat="2|,|." />
    <field name="Staus" alias="Staus" gridfield="false" />
    <field name="Site_Name" alias="Site_Name" gridfield="false" />
    <field name="County" alias="County" gridfield="false" />
   </fields>
   <links/>
   <zoomscale usegeometry="true" zoompercent="1"></zoomscale>
   <autoopendatagrid>false</autoopendatagrid>
   <queryattachments>false</queryattachments>
   <relates/>
   <symbology>
    <simplefillsymbol color="0x0000ff" alpha="0.5">
     <outline color="0x00ffff" alpha="0.8" width="2" />
    </simplefillsymbol>
   </symbology>
  </layer>

 </layers>
....................................

 <spatialrelationships>

 <keepgraphicalsearchenabled>true</keepgraphicalsearchenabled>
 <autozoomtoresults>true</autozoomtoresults>
 <popupsdisabled>false</popupsdisabled>
 <enabledatagridinteractionwithwidget>false</enabledatagridinteractionwithwidget>
 <toleranceforpointgraphicalselection>6</toleranceforpointgraphicalselection><!-- value is in screen pixels -->
 <tolerancebydefault>false</tolerancebydefault>
 <spatialreference>102100</spatialreference>
 <zoomscale>2400</zoomscale>
 <geometryservice>http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer</geometryservice>
 <csvseparator>,</csvseparator>
 <disablebuttons>text,result,spatial,grid,datagrid</disablebuttons><!--possible values one or more not all four search types comma separated text,graphic,spatial,grid,datagrid -->
 <defaultselectionoption>graphicalInput</defaultselectionoption><!--possible values only one graphicalInput or textInput or spatialInput -->
 <enabledrawgraphicbutton>true</enabledrawgraphicbutton>
 <enablebuffergraphicbutton>true</enablebuffergraphicbutton>
 <selectedgraphicaltool>mappoint</selectedgraphicaltool><!-- possible values are extent or polygon or mappoint or polyline or nothing -->
 <multipartgraphicsearch>false</multipartgraphicsearch>
 <floatorfixed>float</floatorfixed><!-- possible values are fixed and float -->
 <relatetooltip>Show Relates</relatetooltip>
 <relateicon>widgets/eSearch/assets/images/i_relate.png</relateicon>
....................................................


That is kind of what I am thinking, of course, this only the relevant parts, not complete xml.
I don't see a photo field, so not sure where you store that info, so I just made it so if it's NOT one of the two counties listed, it should give popup with "fewer" fields, if is in one of the two counties, should give popup will all the fields. (If this works, AND if I didn't make any stupid typos )
If you try and it doesn't give errors, but doesn't work right, would look into the definitionexpression coding.  Would be my most likely mistake other than typos.

Also, I see you are not running a geometry server, I get better "faster" results with queries/searches, etc that utilize it if using my own rather than the default.

Just in case you want to try.  One nice thing about it is that Robert has written it so that everything I mentioned can be done with the eSearchWidget.xml file and no compiling needed (well, again, "if" it can be done )

R_

now that I typed that all up, not sure you can get around having to choose one of the search layers from a dropdown first.  Don't know if it can be configed to search both layers, even with same name, at once as I suspect it will put them both in a dropdown.
0 Kudos