Select to view content in your preferred language

Change Search widget to use selectedColor instead of resultMarkerSymbol

1209
5
01-09-2011 08:47 AM
ChrisBeaudette
Frequent Contributor
I'm trying to figure out how to modify the Search widget in the Flex Viewer so that selected features (points in my case) are highlighted with the "halo effect" using the selectedColor for the FeatureLayer. The widget currently "highlights" the selected features by overlaying the search icon on top of the point (w/ a slight offset). I want to disable the "icon symbol" in favor of a "highlight symbol".

It looks like to disable the "icon symbol" I can simply comment out this line in displayFeatures():
     graphic.symbol = searchResult.symbol = resultMarkerSymbol

But it's not clear to me how to implement the "highlight symbol".  It seems like I have to capture each selected feature and somehow (?) highlight it.

Thanks in advance for any help.
Tags (2)
0 Kudos
5 Replies
DasaPaddock
Esri Regular Contributor
You could try calling queryLayer.selectFeatures() instead of queryLayer.queryFeatures(). This returns an Array of features though instead of a FeatureSet so you'd also need to make some changes to createSearchResults(). It may be easier to just set the highlight on the Graphic yourself in createSearchResults(). You'd need to add a GlowFilter to the Graphic's filters array.

See:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayObject.html#...
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filters/GlowFilter.html

Here's what's used in the FeatureLayer:

            glowFilter = new GlowFilter();
            glowFilter.alpha = 0.6;
            glowFilter.blurX = 16;
            glowFilter.blurY = 16;
            glowFilter.inner = feature.geometry is Polygon;
            glowFilter.strength = 8;
glowFilter.color = selectionColor;
0 Kudos
ChrisBeaudette
Frequent Contributor
You could try calling queryLayer.selectFeatures() instead of queryLayer.queryFeatures(). This returns an Array of features though instead of a FeatureSet so you'd also need to make some changes to createSearchResults(). It may be easier to just set the highlight on the Graphic yourself in createSearchResults(). You'd need to add a GlowFilter to the Graphic's filters array.

See:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayObject.html#...
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filters/GlowFilter.html

Here's what's used in the FeatureLayer:

            glowFilter = new GlowFilter();
            glowFilter.alpha = 0.6;
            glowFilter.blurX = 16;
            glowFilter.blurY = 16;
            glowFilter.inner = feature.geometry is Polygon;
            glowFilter.strength = 8;
glowFilter.color = selectionColor;


Thanks Dasa! 

Thet gets me a lot closer: I was able to add a GlowFilter to each feature in the FeatureSet.  However it's still using the widget icon as a marker and I simply want to highlight the map feature icon as it's symbolized from the server (also a PictureMarkerSymbol).

I commented out this line in init:
     graphicsLayer.symbol = resultMarkerSymbol;

and this one in createSearchResults():
     graphic.symbol = searchResult.symbol = resultMarkerSymbol;

But now the results are displayed with a black circle (with the yellow highlight/GlowFilter) on top of my map icons (see i1.png).  What I'd like to do is mimic the map icon getting highlighted similar when you select a feature to edit using the Edit widget.  i2.png shows the same feature icons but "un-highlighted".
0 Kudos
DasaPaddock
Esri Regular Contributor
Currently the Search Widget doesn't retrieve the server's symbology. Here are a couple of options you could try.

1. Use the DetailsTask to get the LayerDetails and then set the graphicsLayer.renderer to layerDetails.drawingInfo.renderer. Make sure than your getting the fields used by the renderer.

http://help.arcgis.com/en/webapi/flex/apiref/com/esri/ags/tasks/DetailsTask.html#getDetails()

2. Instead of adding a GraphicsLayer to the map, add a FeatureLayer and call selectFeatures() instead of queryFeatures().
0 Kudos
DasaPaddock
Esri Regular Contributor
Actually a better option than 1 above is to get the layerDetails from the FeatureLayer that's already being created.
0 Kudos
DerekHunter
Emerging Contributor
Did you ever get a proper solution??


Thanks Dasa! 

Thet gets me a lot closer: I was able to add a GlowFilter to each feature in the FeatureSet.  However it's still using the widget icon as a marker and I simply want to highlight the map feature icon as it's symbolized from the server (also a PictureMarkerSymbol).

I commented out this line in init:
     graphicsLayer.symbol = resultMarkerSymbol;

and this one in createSearchResults():
     graphic.symbol = searchResult.symbol = resultMarkerSymbol;

But now the results are displayed with a black circle (with the yellow highlight/GlowFilter) on top of my map icons (see i1.png).  What I'd like to do is mimic the map icon getting highlighted similar when you select a feature to edit using the Edit widget.  i2.png shows the same feature icons but "un-highlighted".
0 Kudos