Select to view content in your preferred language

Selection Widget for SFV2.2 (with a query builder)

6591
50
02-21-2011 11:55 AM
MarkHoyland
Occasional Contributor II
The Selection widget has a "Select by Attributes" and "Select by Location" option similar to ArcGIS.
It has options where you can set your selection type eg New Selection, Add to Selection, Remove from Selection.
Select from multiple layers that interstect/contain etc another layer.
You can view the results for each layer in a datagrid, and export to tab delimited text file.

Widget link: http://www.arcgis.com/home/item.html?id=20ed6af9ab204548bbf092d51b51fef8

I built this because it seemed like a fun project and the temptation of a Flex a Widget T-shirt was too much to resist.:o

If you download please leave feedback and rate the widgets (this should apply to any widget you download) as the feed back really helps to know what users are after.
Tags (2)
0 Kudos
50 Replies
MarkHoyland
Occasional Contributor II
KDAGIS(March 4, 2011) 
I really like this widget, thank you! I have one issue. The layers that I have specified to be in the query drop down list get added to the layers I have listed under my More... button. Even though they are already there. So I wind up then having each layer listed twice under my More... button. I've looked around in the code but haven't identified what code I could take out to make it not add the layers to the More.. button. 


Nice pickup, I have looked into this and it seems to be a "feature" of TOC component in the MapSwitcher Widget.
TOC.as in com.esri.viewer.components.toc has en event listener on the map for MapEvent.LAYER_ADD.
It automatically adds the FeatureLayers to the TOC when the map fires the event.

There is a workaround however. In the MapSwitcher.xml file you can tell it to exclude layers.
<layerlist visible="true">
<excludelayer>Louisville Police Facilities</excludelayer>
<excludelayer>Counties</excludelayer>
<excludelayer>States</excludelayer>
</layerlist>


Edit:
Here is a fix for the issue. (Ignore the above workaround.)
Add this listener to the init() function in the SelectionWidget.mxml file. Just add as the first line in init()

private function init():void
{
 map.addEventListener(MapEvent.LAYER_ADD, onLayerAdd, false, 100);

The 100 at the end of the listener gives the listener a high priority.

Add the function in the SelectionWidget.mxml file.

private function onLayerAdd(event:MapEvent):void
{
 event.stopImmediatePropagation();
}


This will stop the TOC.as from being notified that a layer was added to the map.
I will update the source code and recompile on the download page when I get a chance.
0 Kudos
KellyEmmons
New Contributor
Perfect, thanks!  I also had to add:

import com.esri.ags.events.MapEvent;

And that fixed the issue.  Again, this is a great widget.  Thanks!
0 Kudos
AdamRepsher
Regular Contributor
Hi Daniel,
The widget is based on the FlexViewer's built in search widget, with the addition of Robert's unionGeom function. That function is brilliant as it is client side and so quick. It is definately worth looking at what others have done and reusing there work (if permitted of course).

I did think about including graphical selection tools but there were a few widgets that already did this sort of thing, so I decided against it.

But yes a select by Graphic option like ArcGIS would be good.
I will see about adding one.
(I am also happy to include contributions and enhancements from others.)



Mark,
First - Great Widget!  This is what I have been searching for!

I would love it if you did add on a select by graphic.  Yes, others have done it, but not with anything like the full query builder and spatial select that you have created!  🙂

Cheers!
--Adam
0 Kudos
DanielOchoa
Occasional Contributor
Mark,

Interesting problem here....when using your Selection Widget in a flexviewer where Robert Scheitlin's TOC widget is open, the TOC widget populates with whatever layers are placed into the Selection Widget XML. 

Example - Say I have layer one, layer two and layer three in the drop down of the Selection Widget. The selection widget is not set to preload, but the TOC widget is, and lists, say, 3 map services. If I then activate the Selection Widget, as soon as it opens, the TOC widget then lists layer one, layer two and layer three right above the map services in the TOC, and has them turned on.  Unchecking them does nothing - the layer visibility of these additions is not controlled from here. They persist even if the selection widget is turned off. The only way to remove them from the TOC wdiget window is to restart the viewer. So, the addition of these layers to the TOC dont cause any issues, but can be confusing for a potential user to see.

My question - is there any way to prevent or fix it so this doesnt happen?

Thanks
0 Kudos
MarkHoyland
Occasional Contributor II
Interesting problem here....when using your Selection Widget in a flexviewer where Robert Scheitlin's TOC widget is open, the TOC widget populates with whatever layers are placed into the Selection Widget XML.


Please see above fix in this thread to KDAGIS on the 03-07-2011 02:58 PM, as it sounds like the same thing is happening. I will update the source code on the download page with this fix.
0 Kudos
LisaArnold
Deactivated User
Hi Mark,

Thanks for the great widget. I had a couple questions for you.

On the Select by Attribute tab, not all of my unique values for each field are loading. Is there a limit to how many unique values it will load? If not, do you have a suggestion of what I might check to resolve this issue?

I am using the widget on data that doesn't turn on until 1:577,791. If I use the widget zoomed out, where some of my other layers are turned on at 1:4,622,324, the tool returns results but does not draw the highlighting. The selected features are only highlighted/drawn if I am zoomed into the level that the actual layer comes on. Since the widget draws the selection in what I think is a graphics layer it is very fast, so i would like it to show up at the zoomed out scale even though the actual map service layer won't draw until the user zooms to a feature. Is there a way to make this happen?

Thanks for your help!
0 Kudos
francescodi_vito
Deactivated User
hy guys, I downloaded this widget and it's great.
But i have a problems with one field of my map service. the field is set on YES/NO, and when i run the selct by attribute for the YES value all it's ok, but when i set the select for NO value i have a #1009 error and say me that "TypeError: Error # 1009: Can not access a property or method of a null object reference." but but despite this i have a result on a map.
Why?
help me
0 Kudos
City_of_Port_Angeles_GIS
New Contributor III
Mark,
   I seem to be having the same type of problem that Sertac TAKIL was having. When I run a query on just a few point items, the icons show at the correct places. But if I run a query with a lot of point items, the icons are incorrectly placed. This seems to happen only with point data. My polygon data(e.g. Parcels) do not display this behavior. Here is a little bit of oddness associated with this behavior: when the query builder first returns the queried items the basemap flips upside-down then right-side up. The icons are being placed on the upside-down map so when the map flips right-side up the icons are incorrectly placed. Any idea what could be causing this? I am using ArcServer 9.3.1 and FlexViewer 2.2. My site is intended for our utility crews and in-house staff so is not publicly available. Any help would be appreciated.
Thanks,
Billy
0 Kudos
MarkHoyland
Occasional Contributor II
Lisa,
List not showing all unique values is to do with an ArcGIS Server setting which controls the amount of features allowed to be returned. The setting can be changed in the server. See the comments on the page where you can download the Selection widget as there is an answer in one of the comments.
I am also currently investigating the paging method to retreive the result as this will get all results regardless of the setting. (One of the esri samples uses paging.)

As for the scale issue,the results are returned to a flex featurelayer, which is similar to a graphicslayer, but the featurelayer is based on the actual layer in the msd/mxd. The scale dependant setting is inherited from the mxd/msd.
There is a minscale, maxscale property that can be set for the featurelayer, so yes what you want can be done.

If you want to add this yourself for all layers you can add the two lines in bold below to the init() function in SelectionWidget.MXML.
I will however add this functionality as a configurable option when I get a chance to update the source code.

for (var i:int = 0; i < lyrList.length(); i++)
{
 var lyrURL:String = lyrList.url;
 var lyrLabel:String = lyrList.name;
 
 var featureLayer:FeatureLayer = new FeatureLayer(lyrURL);
 featureLayer.name = lyrLabel;
 featureLayer.minScale = 0;
 featureLayer.maxScale = 0;
 featureLayer.addEventListener(LayerEvent.LOAD, featureLayer_loadHandler);
}
0 Kudos
MarkHoyland
Occasional Contributor II
francesco,
Is your data available to the public?
Is this a text field that has a value of YES/NO ?
If you can run the code from within flashbuilder can you post the full error message or the line that the error occurs on.
0 Kudos