Select to view content in your preferred language

Highlight features on a featurelayer after query

5168
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
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

You need to set the outSpatialReference to the views spatialReference

View solution in original post

0 Kudos
17 Replies
RobertScheitlin__GISP
MVP Emeritus

You can use featurelayer.selectFeatures

As in this sample: Select features within a two minute drive time | ArcGIS API for JavaScript 3.19 

0 Kudos
EvonFranklin
Regular Contributor

I am using API 4.2 though

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Evon,

  Sorry I did not see any tags or text saying that. Currently there is no selectFeatures method on FeatureLayer so the option you have is to add a graphic based on the geometry result from the query with your desired symbology assigned.

0 Kudos
EvonFranklin
Regular Contributor

Ok I have begun looking into adding graphics, but after adding graphics to the "map.graphics.add(graphic)" I see no changes being reflected on the map. I check the console for the geometry and it seems to have data present for each graphic but I am not sure if they are being displayed elsewhere or there is another issue preventing the graphics from being displayed. The query is successful and returns 63 results.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Evon,

   I personally would create my own graphicslayer. You need to ensure that your returned geometry is in the map wkid and that you are creating new graphic object not just adding the ones returned from the Query.

0 Kudos
EvonFranklin
Regular Contributor

I will continue to do some testing with this, is there a sample you could point me to? I am currently creating a new graphic adding the needed attributes then adding it to a new graphics layer I created and added to the map via "map.add(grphLayer);"

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Evon,

   There is this sample:

ArcGIS API for JavaScript Sandbox 

But not specific to adding from a query result.

EvonFranklin
Regular Contributor

Thank you for your tips and advice, I will continue to experiment with this, I realize now that 4.x is really new so many things are left out.

0 Kudos
EvonFranklin
Regular Contributor

I have tried the sample code and it does work, so there may be an issue with the geometry being returned from my service however how do I then debug my geometry to see what it shape it returns or check if it is a valid shape? I have logged the geometry and there are values present.

0 Kudos