Dynamically show/hide feature graphic in the map
I am building a GVH Module to filter the map based on a specific criteria. How can I write code in the TypeScript to show/hide graphic in the map. For example, I try this code below. The object myLayer is given and I want to query the layer for the features having the Restriced attribute = "1". Then, hide those features in the map. I got the features in the result but couldn't hide the graphic in the map. Please help.
var query = new esri.tasks.Query();
query.where = "Restricted=1";
query.returnGeometry = true;
let queryTask = getQueryTask(myLayer);
queryTask.execute(query, (results: esri.tasks.FeatureSet) => {
var esriFeatureSet = new esri.tasks.FeatureSet(results);
var featureSet = new FeatureSet({
esriFeatureSet: esriFeatureSet,
layer: myLayer,
app: this.app
});
for (let i = 0; i < featureSet.features.length(); i++) {
var feature = featureSet.features.getAt(i);
var graphic = MapUtils.findFeatureInMap(feature.esriFeature.get(), this.app.site);
// graphic return null
if(graphic) {
graphic.hide();
}
}
}, (e: Error) => {
this.app.trace.error("Query failed: " + e.message);
});
Thanks,
Tony
0
-
Clarifying question: is there a reason you couldn't do this with a workflow instead? Query Layer Definition works great for hiding/showing features based on attribute values. 0 -
That is a good question. I am new to GeoCortex Essential so I am not sure whether workflow can do the following things.
1. Need to add a button into the toolbox to open a filter form. (We don't use "I want to" menu for this one)
2. Add custom HTML widgets (i.e. slider, date picker) into the form
3. Build a custom layout for the form. For example, we need 2 columns for 2 textboxes in one row instead of one column with all widgets
4. Implement cadecase selection dropdown lists and onClick events
5. Dynamically show/hide feature in the map based on the button click events and dropdown selection change events0 -
Some of that is pretty easy to set up, but some of it you can't do without custom programming.
1. On the toolbar, you'll Add a button and use the command RunWorkflowById or RunWorkflowWithArguments with your workflow ID and/or arguments as the parameters.
2) Would require custom programming
3) Would require custom programming
4) I don't know what that is
5) Buttons are doable with Display Forms and the Set Layer Definition activity. I don't know about dropdown selection changes, but if it's possible it'd require custom programming.0
Please sign in to leave a comment.
Comments
3 comments