Select to view content in your preferred language

Highlight features on a featurelayer after query

5777
17
Jump to solution
01-12-2017 12:41 PM
EvonFranklin
Regular Contributor

How do I highlight features on a featurelayer after query is run?

0 Kudos
17 Replies
RobertScheitlin__GISP
MVP Emeritus

Evon,

  Are you setting the Query.outSpatialReference?

0 Kudos
EvonFranklin
Regular Contributor

In the query this is what I have 

var queryTask = new QueryTask({
                                             url:urlLink
                                                });
var query = new Query();
var geometry = null;
query.returnGeometry = true;
query.outFields = ["*"];
query.where = "CONST_NAME LIKE '%"+searchString+"%'";

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

You need to set the outSpatialReference to the views spatialReference

0 Kudos
EvonFranklin
Regular Contributor

Should the URL for the QueryTask be to a 

"..../FeatureServer/1" or "..../MapServer/1" ending

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

either is fine.

0 Kudos
EvonFranklin
Regular Contributor

Ok I changed it to FeatureServer and added the spatialRef and it seems to be working now, however it did not show an error in the console which worries me as these silent errors are hard to debug. Thanks much for your help  

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Evon,

   It really was not an error at all the graphic were just being added to the map in their native WKID which was different from the maps wkid so they were probably over in Africa somewhere. You just need to understand that if the map service is in a spatial reference other than the views then you need to specify that the querys outspatialreference needs to be the same as the views.

0 Kudos
EvonFranklin
Regular Contributor

I over looked this fact based on the other layers that were being drawn over more or less the correct region. I have learnt something today for sure.

0 Kudos