selected feature still in special colour even if the query widget is closed

4041
3
Jump to solution
03-03-2015 11:57 PM
KoseWong
New Contributor

Hi,

In my query widget, I have a function to select feature on a layer. The selected feature will in special colour compare to other features in the same layer. But what I want is to display the selected feature in special colour only when the widget is opened. Any ideas.

My code for selecting feature as posted below:

var query:Query = new Query;
query.where = "POST_CODE LIKE '" + txt_PostCode.text + "'";

query.outSpatialReference = map.spatialReference;

query.returnGeometry=true;

queryTask.execute(query, new AsyncResponder(onResult, onFault));

function onResult(resultSet:FeatureSet, token:Object = null):void

{

  graphicsLayer.clear();  

  if (resultSet.features.length == 0){  

  Alert.show("No feature returned, please try again.","ATTENTION");  

  }else{  

      var finalExtent:Extent;  

      var stGraphic:Graphic = resultSet.features[0];  

      finalExtent = Polyline(stGraphic.geometry).extent;  

      resultLineSymbol = new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, 0xFF0000, 0.7, 5);

      graphicsLayer.symbol = resultLineSymbol;

      for each (var graphic:Graphic in resultSet.features){

          stGraphic = new Graphic(graphic.geometry);

          graphicsLayer.add(graphic);  

          finalExtent = finalExtent.union(Polyline(graphic.geometry).extent);

      }   

      map.extent = finalExtent; 

   }

}

function onFault(info:Object, token:Object = null):void 

  { 

      Alert.show(info.toString()); 

  } 

Thank you.

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Kose,

  Just hide your graphicsLayer in the widgets close event and then show it when the widget is opened again.

            private function widgetClosedHandler(event:Event):void
            {
                if (shareResults)
                {
                    map.removeLayer(resultFeatureLayer);
                }
                else
                {
                    resultFeatureLayer.visible = false;
                }
                stopWidgetTimer();
                hideInfoWindow();
               graphicsLayer.visible = false;
            }

View solution in original post

0 Kudos
3 Replies
RobertScheitlin__GISP
MVP Emeritus

Kose,

  Just hide your graphicsLayer in the widgets close event and then show it when the widget is opened again.

            private function widgetClosedHandler(event:Event):void
            {
                if (shareResults)
                {
                    map.removeLayer(resultFeatureLayer);
                }
                else
                {
                    resultFeatureLayer.visible = false;
                }
                stopWidgetTimer();
                hideInfoWindow();
               graphicsLayer.visible = false;
            }
0 Kudos
KoseWong
New Contributor

Hi Robert,

Thanks for the reply and sorry for the late response. I still got the following errors:

access of undefined property:

resultFeatureLayer

shareResults

stopWidgetTimer

hideInfoWindow

I will try to figure it out, thank you.

0 Kudos
KoseWong
New Contributor

Hi Robert,

Got it worked, thank you!

0 Kudos