petco_gis

Spatial Query Using Draw(Polyline) and Polygon

Discussion created by petco_gis on Oct 25, 2013
Latest reply on Oct 29, 2013 by petco_gis
Hey Everyone

I am trying to create a spatial query using a polyline from the draw toolbar and an existing polygon dataset.  I would like to have the value of each polygon put into an array based on the order they are drawn over.  Currently I am using SPATIAL_REL_CROSS but it is placing the values into the array in a different order than I need.  I believe this has to do with the spatialRelationship type but have not been able to figure it out.  Any help would be greatly appreciated!

The idea behind this functionality was based on the following Flex widget:

Elevation Profiler


var polygonLayer = new esri.layers.FeatureLayer("***Feature Layer***",{
mode: esri.layers.FeatureLayer.MODE_SELECTION,
outFields: ['*']
});

var symbol;
symbol = new esri.symbol.SimpleFillSymbol();
var graphic = new esri.Graphic(evt.geometry, symbol);
map.graphics.add(graphic);

var spatialQuery = new esri.tasks.Query();
spatialQuery.spatialRelationship = esri.tasks.Query.SPATIAL_REL_CROSS;
spatialQuery.geometry = graphic.geometry;

polygonLayer.selectFeatures(spatialQuery, esri.layers.FeatureLayer.SELECTION_NEW, function(results){
  var sumValues = [];
  for(var i = 0; i < results.length; i++){
   sumValues.push(results[i].attributes['Sum_Values2']);
  }

Jeremy

Outcomes