Select to view content in your preferred language

Use buffer extent to query layer

1129
6
11-30-2016 08:37 AM
by Anonymous User
Not applicable

Hi all,

I am trying to use the buffer extent into my query but I am not successful. Any idea why I get the following error?

Thanks,

Alex

arrayUtil.forEach(bufferedGeometries, function (geometry) {
                      var graphic = new Graphic(geometry, symbol);
                      map.setExtent(graphicsUtils.graphicsExtent(graphic), true);
                      map.graphics.add(graphic);
                      var queryTask = new QueryTask("http://itas46:6080/arcgis/rest/services/Alex_test/TreeMortalityLayers/MapServer/9");
                      var query = new Query();
                      query.returnGeometry = true;
                      query.geometry = geometry;
                      query.outFields = ["OWNER_NAME", "OWNER_ADDR", "OWNER_CITY"];
                      query.outSpatialReference = map.spatialReference;
                      queryTask.execute(query, addToMap);
                  });

              }
              function addToMap(results) {
                  var symbol8 = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
                                   new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
                                     new Color([255, 0, 0]), 3), new Color([18, 29, 224, 0.35]));
                  var featureArray = results.features;
                  if (featureArray && featureArray.length > 0) {
                      // do stuff with the features
                      arrayUtils.forEach(featureArray, function (feat) {
                          feat.setSymbol(symbol8);
                          map.graphics.add(feat);
                      });
                  } else {
                      alert("No features found")
                  }
Tags (2)
0 Kudos
6 Replies
RobertScheitlin__GISP
MVP Emeritus

Alex,

 Can you expand the first error and screenshot again?

0 Kudos
by Anonymous User
Not applicable

0 Kudos
by Anonymous User
Not applicable

It now works but I still get an error. Not too sure why.

Code: 

arrayUtil.forEach(bufferedGeometries, function (geometry) {
var graphic = new Graphic(geometry, symbol);
map.graphics.add(graphic);
var queryTask = new QueryTask("http://itas46:6080/arcgis/rest/services/Alex_test/TreeMortalityLayers/MapServer/9");
var query = new Query();
query.returnGeometry = true;
query.spatialRelationship = Query.SPATIAL_REL_INTERSECTS;
query.geometry = graphic.geometry;
query.outFields = ["OWNER_NAME", "OWNER_ADDR", "OWNER_CITY"];
query.outSpatialReference = map.spatialReference;
queryTask.execute(query, queryCallback);
});

}
function queryCallback(featureSet) {
var symbol = new SimpleFillSymbol(
SimpleFillSymbol.STYLE_SOLID,
new SimpleLineSymbol(
SimpleLineSymbol.STYLE_SOLID,
new Color([255, 0, 0, 0.65]), 2
),
new Color([255, 0, 0, 0.35])
);

var features = featureSet.features;
dojo.forEach(features, function (feature) {
feature.setSymbol(symbol);
map.graphics.add(feature);
});
}

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Alex,

  What is line 384 - 386 in your index.html?

0 Kudos
by Anonymous User
Not applicable

That is this:

arrayUtil.forEach(bufferedGeometries, function (geometry) {
var graphic = new Graphic(geometry, symbol);
map.graphics.add(graphic);

0 Kudos
by Anonymous User
Not applicable

However, I just get that error now:

0 Kudos