Select to view content in your preferred language

Querying a feature layer

4438
5
Jump to solution
01-13-2015 09:50 AM
IbrahimHussein
Deactivated User

Hey guys, I am trying to filter out the geometries in a feature layer using a select box.

In c# you could just do a query on a layer then use the function featureLayerName.Update(); to refresh.

In javascript, I have something like this

query.where = "argument"

featureLayerName.selectFeatures(query, FeatureLayer.MODE_SNAPSHOT, function(results){

  featureLayerName.refresh();

});

I did a queryCount and it returned the correct count, which tells me the query is working just fine. so I must be doing something wrong after I get the results.

heres a fiddle

the code in question is in the councilFilter() function.

Thanks.

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Ibrahim,

   If you only want to show the selected district then do not do a selection at all and just set the layers definition query

Here is a updated JSFiddle

View solution in original post

5 Replies
RobertScheitlin__GISP
MVP Emeritus

Ibrahim,

  You need to set a selection symbol for the councilDistrictLayer.

      var selectionSymbol = new SimpleFillSymbol().setColor(new Color([255,255,0,0.5]));
      councilDistrictLayer.setSelectionSymbol(selectionSymbol);
IbrahimHussein
Deactivated User

Thanks for the reply, I did do that earlier but that what I'm trying to do is only show the selected geometry.

0 Kudos
IbrahimHussein
Deactivated User

Ok, what I did was

  1. var selectionSymbol = new SimpleFillSymbol().setColor(new Color([0,0,0,0])); 
  2.       councilDistrictLayer.setSelectionSymbol(selectionSymbol); 

Like Robert suggested, but in the query I did a <> (not equal) that way it selects all others and turns the alpha to 0.

Im sure there is a better way to do it, but in case anyone comes across the same issue, that's how I did it.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Ibrahim,

   If you only want to show the selected district then do not do a selection at all and just set the layers definition query

Here is a updated JSFiddle

IbrahimHussein
Deactivated User

I knew there was some function I missed, thanks for all the help robert.

0 Kudos