not getting any selection results, JSAPI 3.21 with WABuilder 2.5

478
3
Jump to solution
03-22-2018 03:37 PM
MattBorden
New Contributor II
I'm using JSAPI 3.21 with WABuilder 2.5, getting the below error, not sure why?
my guess is maybe a bad where clause and not getting any selection results, or bad syntax and not using selection results correctly with JSAPI, any help would be great
thanks Matt
"esri/tasks/query",
"esri/graphic",
...
function(
...
Query,
Graphic,
//get layer
var currentLayer = this.map.getLayer(this.map.graphicsLayerIds[1]);
//create query
var query = new Query();
query.where = "parcel_id = '01364000010000'";

//query to get selection on feature layer
currentLayer.selectFeatures(query);
//get the extent
theExtent = currentLayer.getSelectedFeatures().geometry.getExtent();
//zoom to map extent
this.map.setExtent(theExtent);
debug results from chrome dev tools
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Matt,

  Here is a quick example of working with the deferred:

curentLayer.selectFeatures(query, function(result){
  //todo work with the selection result
  //now that the selection is complete
});

View solution in original post

3 Replies
RobertScheitlin__GISP
MVP Emeritus

Matt,


  It looks like you need to wait for the selection method to complete before you try and access the selected feature. The select features method returns a deferred so you need to wait for the deferred to resolve.

MattBorden
New Contributor II

thanks for the tip Robert, I'm trying timeouts and promises to see if this fixes it, I'll share the results when I have them

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Matt,

  Here is a quick example of working with the deferred:

curentLayer.selectFeatures(query, function(result){
  //todo work with the selection result
  //now that the selection is complete
});