Dynamic layers and the Search Widget

2850
4
Jump to solution
10-17-2014 10:19 AM
matthewweber
New Contributor III

I am working with grouped layers for the first time in FlexViewer 3.6. I have an .mxd with several (about 50) layers set into 7 groups. While I can get everything to display nicely in the TOC, I cannot get the search tool to function correctly. I think it has to do with the use of sub-layers, as dynamic layers are new to me and I'm fumbling my way through (ESRI does not provide much of info on their use, or maybe I'm just a goober).

When I fire up the Search widget, I get an E0011E: Invalid feature layer error. My main config file looks like this:

<operationallayers>

            <layer type="dynamic" visible="true" label="SWITRS Incidents" url="http://d16-da/arcgis/rest/services/SWITRS_New_10/MapServer/"/>

     <sublayer id="0"/>

  </operationallayers>

I find it strange that by setting a single sublayer, I can see all the layers/groups in my .mxd. I thought I would have to set a sublayer for each...

The .xml for the search widget is:

<layers>

        <layer>

            <name>Valley Division</name>

            <url>http://d16-da/arcgis/rest/services/SWITRS_New_10/MapServer/</url>

            <expression>COLLISION_ LIKE '%[value]%'</expression>

            <textsearchlabel>Search by Incident Date [ Example: 6/7/2006 or %2009]</textsearchlabel>

            <titlefield>SWITRS Incidents</titlefield>

            <fields all="false">

  <field name="PRIMARY_RD"/>

  <field name="SECONDARY_"/>

  <field name="COLLISION_" alias="Incident Date"/>

     <format dateformat="shortDate"/>

            </fields>

     <symbol>

  <simplemarkersymbol color="0xFF0000" size="5" style="circle" />

            </symbol>

        </layer>

    </layers>    

So anyone see anything wrong right off the bat? Am I using dynamic layers or grouped layers incorrectly? Do dynamic layers even work with the search tool? Any advice on using dynamic and grouped layers is greatly appreciated.

Thanks!

Matthew Weber

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Matthew,

  Sorry, I did not mention feature type layer because I wanted you to switch to that. Feature Type Layers will only show on subLayer of a map Service (as you are seeing), it is not an option for displaying grouped layers. The only layer type that will display grouped layers is dynamic.

As far as my example of:

i.e.

<url>http://d16-da/arcgis/rest/services/SWITRS_New_10/MapServer/0</url>

if layer id 0 is a group layer than you can not use 0 you have to search a actual sublayer and not a group.

View solution in original post

4 Replies
RobertScheitlin__GISP
MVP Emeritus

Matthew,

   Yes, right off the bat I see that you have some issue with your understanding of dynamic layer use. The fact that you have sublayer element in your layer with type dynamic that has no attributes but id specified, actually does nothing at all for you. Setting a layer as type dynamic basically adds all the sublayer of the map service to your map and the use of the sublayer element is for definitionexpressions and popupconfig use only as documented here: ArcGIS Viewer for Flex - Dynamic, Tiled, Feature, and Image layer types

It seems like you are thinking that specifying the sublayer will limit the dynamic layer to only displaying that sublayer id, and that would be incorrect.

Now on the the issue with your search widget xml configuration. The search widget is designed to search one sublayer of a dynamic map service layer or the specific layer that the layer type of feature points to. So your url tag in your searchWidget.xml should contain the specific layer id of the mapservice that you wish to search on.

i.e.

<url>http://d16-da/arcgis/rest/services/SWITRS_New_10/MapServer/0</url>

Hope this clears things up for you

matthewweber
New Contributor III

Thanks Robert,

So when I set the service type to feature, I cannot get my subgroups to display properly. The first layer in the group is "Valley Division" <layer type="feature" visible="true" label="Valley Division" url="http://d16-da/arcgis/rest/services/SWITRS_New_10/MapServer/0"/>This layer contains all the data in the sublayers below it in the group that comprise this division.

The first sublayer in the group below Valley Division is "Amador" <layer type="feature" visible="true" label="Amador Office" url="http://d16-da/arcgis/rest/services/SWITRS_New_10/MapServer/1"/>

The next sublayer is "Auburn" <layer type="feature" visible="true" label="Auburn Office" url="http://d16-da/arcgis/rest/services/SWITRS_New_10/MapServer/2"/>

Now this format doesn't seem to work. I don't want to add all 50 layers individually, I would to keep them as layer groups. So users can view/search a whole division, or drill down into the smaller area office geographies.

When I set the search widget to <url>http://d16-da/arcgis/rest/services/SWITRS_New_10/MapServer/0</url> it gives me the same error as the one in my original posting. So again I think the problem is in using the grouped layers, but maybe not, I defer to you great wisdom...

If there is an more info I can provide, screenshots of the viewer or the .mxd etc, let me know.

0 Kudos
matthewweber
New Contributor III

Here is how it displays if added as feature layers (they are still grouped in the .mxd). I would like Amador to be a sublayer under Valley Division.SWITRS Ungrouped.png

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Matthew,

  Sorry, I did not mention feature type layer because I wanted you to switch to that. Feature Type Layers will only show on subLayer of a map Service (as you are seeing), it is not an option for displaying grouped layers. The only layer type that will display grouped layers is dynamic.

As far as my example of:

i.e.

<url>http://d16-da/arcgis/rest/services/SWITRS_New_10/MapServer/0</url>

if layer id 0 is a group layer than you can not use 0 you have to search a actual sublayer and not a group.