AnsweredAssumed Answered

Query geometry issue

Question asked by endlessdsire on Jun 14, 2016
Latest reply on Jun 14, 2016 by endlessdsire

I am trying to get the results from a FeatureLayer when the user clicks on the map.

 

My geometry is an map.MapPoint that i pass to the following function.

 

I tried to make a rectangle for making a polygon to add more range to the results but for some reasonim getting an error performing the query

 

function factigis_findDireccion(geometry,callback){
  var rectangulo = new esri.geometry.Polygon;
  rectangulo.addRing(crearRectangulo(geometry,1));

  console.log("my point",rectangulo);
  var qTaskInterruptions = new esri.tasks.QueryTask(layers.read_direcciones());
  var qInterruptions = new esri.tasks.Query();


  qInterruptions.returnGeometry = true;
  qInterruptions.outFields=["id_direccion","nombre_calle","numero"];
  qInterruptions.geometry = rectangulo ;
  qInterruptions.spatialRelationship = esri.tasks.Query.SPATIAL_REL_CONTAINS;


  qTaskInterruptions.execute(qInterruptions, (featureSet)=>{
    console.log("Find",featureSet);
    callback(featureSet.features);
  }, (Errorq)=>{
    console.log(Errorq,"Error doing interruptions nis by extent");
      return 0;
  });
}


function crearRectangulo(mapPoint,delta){
  var arrayOfPoints = new Array();


  arrayOfPoints[0] = new esri.geometry.Point(mapPoint.x-delta,mapPoint.y-delta,mapPoint.spatialReference);
  arrayOfPoints[1] = new esri.geometry.Point(mapPoint.x-delta,mapPoint.y+delta,mapPoint.spatialReference);
  arrayOfPoints[2] = new esri.geometry.Point(mapPoint.x+delta,mapPoint.y+delta,mapPoint.spatialReference);
  arrayOfPoints[3] = new esri.geometry.Point(mapPoint.x+delta,mapPoint.y-delta,mapPoint.spatialReference);
  arrayOfPoints[4] = new esri.geometry.Point(mapPoint.x-delta,mapPoint.y-delta,mapPoint.spatialReference);


  return arrayOfPoints;
}

 

What im missing? thanks for ur help

Outcomes