Is it Possible to get prop_id for each Parcels selected in a buffer results, so I can pass them to SQL query, for example if the buffer return 10 parcels I need to get all the prop_id for the 10 parcels..
_showBuffer: function(features){
$('.results.multipleBuffer').hide();
var bufferSymbol = symbols.buffer;
map.graphics.clear();
if (features.length > 0) {
var graphic = new Graphic(features[0], bufferSymbol);
map.graphics.add(graphic);
queryTask = new QueryTask(config.mapServices.dynamic + "/" + config.parcelLayerID);
var bufferQuery = new Query();
bufferQuery.outFields = ["*"];
bufferQuery.returnGeometry = true;
bufferQuery.geometry = features[0];
queryTask.execute(bufferQuery).then(lang.hitch( this, function (fset) {
var bufferFeatures = fset.features;
console.log(bufferFeatures);
this._createTable(bufferFeatures);
//console.log(bufferFeatures);
navEvent('point');
if (fset.features.length > 0) {
var allGraphics = array.map(fset.features, function (feature) {
return feature;
});
unionExtent = graphicsUtils.graphicsExtent(allGraphics);
map.setExtent(unionExtent.expand(1.5));
}
}));
}
},
Solved! Go to Solution.
Husham,
You are already looping through the results so it would simply be something like this:
if (fset.features.length > 0) {
var Gids = [];
var allGraphics = array.map(fset.features, function (feature) {
Gids.push(feature.attributes.prop_id);
return feature;
});
unionExtent = graphicsUtils.graphicsExtent(allGraphics);
map.setExtent(unionExtent.expand(1.5));
}
//Then you use the Gids array to populate your SQL query i.e. var sqlText = "Select * from TableX Where FieldX IN (" + Gids.join() + ")";
Husham,
Sure you can. You already have the graphics that are selected based on intersecting the buffer(s). So you would loop through the fset.features and once you have a single feature (i.e. var feat = fset.features😉 then you would get that features attributes property and then the field you are interested in (i.e. fset.features[0].attributes.prop_id).
Thank you Robert, Could you please provide code sample for the loop.
Regards
Husham,
You are already looping through the results so it would simply be something like this:
if (fset.features.length > 0) {
var Gids = [];
var allGraphics = array.map(fset.features, function (feature) {
Gids.push(feature.attributes.prop_id);
return feature;
});
unionExtent = graphicsUtils.graphicsExtent(allGraphics);
map.setExtent(unionExtent.expand(1.5));
}
//Then you use the Gids array to populate your SQL query i.e. var sqlText = "Select * from TableX Where FieldX IN (" + Gids.join() + ")";
Robert,
That is really great Help.
Thank you