how to highlight feature layer with arcgis 10.5.1

714
4
Jump to solution
09-26-2018 11:45 AM
GotQuestion
New Contributor II

I'm a n00b and I understand that the following only works with 10.6.1 enterprise server 

layerView.highlight(results.features[0].attributes.OBJECTID) 

however, I have 10.5.1 server and would like to know how to achieve the same thing?

Apparently I can use SceneView

But how do I convert my 

map.add(featureLayer)

to a sceneview so highlihght works?

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Grave,

   Sure here is a code snippet for that:

// Create a symbol for rendering the graphic
var fillSymbol = {
  type: "simple-fill", // autocasts as new SimpleFillSymbol()
  color: [111, 0, 255, 0.3],
  outline: { // autocasts as new SimpleLineSymbol()
    color: [111, 0, 255],
    width: 1
  }
};

...

view.graphics.removeAll();
var query = yourFeatureLayer.createQuery();
query.where = "PARCELID = 'blah blah'";
var deferred = yourFeatureLayer.queryFeatures(query).then(function (selection) {
  var polygonGraphic = new Graphic({
    geometry: selection.features[0].geometry,
    symbol: fillSymbol
  });
  view.graphics.add(polygonGraphic);
});

View solution in original post

4 Replies
RobertScheitlin__GISP
MVP Emeritus

Grave,

  You do not need to convert to a scene view you just stick with a MapView and use a GraphicsLayer to add a graphic to to represent your selection.

0 Kudos
GotQuestion
New Contributor II

thanks Robert. I've been exploring that concept but I don't understand how to 

make a graphic that matches the shape of results.features[0].attributes.OBJECTID

so that it only highlights that particular objectid on the featurelayer.

could you point me to an example of that?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Grave,

   Sure here is a code snippet for that:

// Create a symbol for rendering the graphic
var fillSymbol = {
  type: "simple-fill", // autocasts as new SimpleFillSymbol()
  color: [111, 0, 255, 0.3],
  outline: { // autocasts as new SimpleLineSymbol()
    color: [111, 0, 255],
    width: 1
  }
};

...

view.graphics.removeAll();
var query = yourFeatureLayer.createQuery();
query.where = "PARCELID = 'blah blah'";
var deferred = yourFeatureLayer.queryFeatures(query).then(function (selection) {
  var polygonGraphic = new Graphic({
    geometry: selection.features[0].geometry,
    symbol: fillSymbol
  });
  view.graphics.add(polygonGraphic);
});
GotQuestion
New Contributor II

Thank you!!!

0 Kudos