Select to view content in your preferred language

Custom Query Widget

1806
3
02-04-2013 10:51 AM
DanielMunoz
Regular Contributor
Hello All!

I'm would like to customize the Query Widget 3.1 to display the return results with three different icons instead of a single icon (fire.png police.png ems.png) according to the values on the queried field.

<query> Agency_Type = 'F' OR Agency_Type = 'P' OR Agency_Type = 'M'</query>

Any help, suggestions, directions would be greatly appreciated.

[ATTACH=CONFIG]21409[/ATTACH]
Tags (2)
0 Kudos
3 Replies
AnthonyGiles
Honored Contributor
Daniel,

You will need to modify the createQueryResults function. In the for each (var graphic:Graphic in featureSet.features) statement do something similar to what you did in the live layer widget on your post here:

http://forums.arcgis.com/threads/23561-QueryWidget?highlight=result+symbol

then remove the symbology being added under the switch (featureSet.geometryType).

Regards

Anthony
0 Kudos
DanielMunoz
Regular Contributor
Anthony,

Thank you for your reply, as you saw I have been using this mod to QueryWidget since it used to be the LiveLayer until version 3.0 of the viewer. Unfortunately the code on version 3.1 changed a lot and I'm totally lost (not a programmer) but reading your post gave the idea of bringing the QueryWidget 3.0 into 3.1 and worked, not the best and probably would come back to hunt me.

This is a great mod to differentiate the query results with different icons, I would like to believe someone else out there is doing the same mod and would post the update sometime so i can keep up with the viewer for flex updates.

Daniel
0 Kudos
RichardButgereit
Regular Contributor
I got a customized query widget to work with 3.4 with the following enhancements --

-- Declare any new marker symbols you'll need...

private var resultMarkerSymbol:Symbol;
private var resultMarkerSymbol1:Symbol;
private var resultMarkerSymbol2:Symbol;   
private var resultMarkerSymbol3:Symbol;   
private var resultMarkerSymbol4:Symbol;   
private var resultMarkerSymbol5:Symbol;


-- After marker symbol is defined...

//marker symbol
const resultMarkerSymbolURL:String = configXML.symbols.picturemarkersymbol.@url || widgetIcon;
const parsedResultMarkerSymbolHeight:Number = parseFloat(configXML.symbols.picturemarkersymbol.@height[0]);
const resultMarkerSymbolHeight:Number = isNaN(parsedResultMarkerSymbolHeight) ? 0 : parsedResultMarkerSymbolHeight;
const parsedResultMarkerSymbolWidth:Number = parseFloat(configXML.symbols.picturemarkersymbol.@width[0]);
const resultMarkerSymbolWidth:Number = isNaN(parsedResultMarkerSymbolWidth) ? 0 : parsedResultMarkerSymbolWidth;
const resultMarkerSymbolXOffset:Number = (configXML.symbols.picturemarkersymbol.@xoffset != null) ? configXML.symbols.picturemarkersymbol.@xoffset : 0;
const resultMarkerSymbolYOffset:Number = (configXML.symbols.picturemarkersymbol.@yoffset != null) ? configXML.symbols.picturemarkersymbol.@yoffset : 0;
resultMarkerSymbol = new PictureMarkerSymbol(resultMarkerSymbolURL, resultMarkerSymbolWidth, resultMarkerSymbolHeight, resultMarkerSymbolXOffset, resultMarkerSymbolYOffset);


-- Add any custom marker symbols you may need...

//special markers for classified values -- one for each value to be symbolized
resultMarkerSymbol1 = new PictureMarkerSymbol("assets/images/i_hydro_green.png", resultMarkerSymbolWidth, resultMarkerSymbolHeight, resultMarkerSymbolXOffset, resultMarkerSymbolYOffset);
resultMarkerSymbol2 = new PictureMarkerSymbol("assets/images/i_hydro_yellow.png", resultMarkerSymbolWidth, resultMarkerSymbolHeight, resultMarkerSymbolXOffset, resultMarkerSymbolYOffset);

    
-- In createQueryResults, after setting the infoWindowRenderer, add code setting a graphic symbol for each desired value. I am classifying by "Stage" and only showing a few of the values by which to classify...

var infoWindowRenderer:ClassFactory = new ClassFactory(PopUpRenderer);
infoWindowRenderer.properties = { popUpInfo: configurePopUpInfo(resultAttributes)};
graphic.infoWindowRenderer = infoWindowRenderer;

var fieldNameTextValue:String = graphic.attributes["Stage"];
if (fieldNameTextValue == "normal")
{
     graphic.symbol = resultMarkerSymbol1       
}
else if (fieldNameTextValue == "action")
{
     graphic.symbol = resultMarkerSymbol2               
}
else
{
     //leave a default marker if needed
     graphic.symbol = resultMarkerSymbol
}


- In the case statement below that, comment out setting a renderer for the whole layer

case Geometry.MAPPOINT:
     {
 //resultFeatureLayer.renderer = new SimpleRenderer(resultMarkerSymbol);
 break;
      }


That worked for me with a point layer -- more would have to be done with lines and/or polygons.
0 Kudos