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?
Solved! Go to Solution.
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);
});
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.
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?
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);
});
Thank you!!!