burton449

TypeError: a.spatialReference is undefined on a selectFeatures()

Discussion created by burton449 on Jan 20, 2014
Latest reply on Jan 20, 2014 by burton449
I use a draw tool to select features like this:

function SelectTool(map) {
    featureLayer = new esri.layers.FeatureLayer("http://localhost:6080/arcgis/rest/services/carte1/MapServer/0", {
      mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
      outFields: ["*"]
     });
     
      selectionToolbar = new esri.toolbars.Draw(map);
      selectionToolbar.activate(esri.toolbars.Draw.FREEHAND_POLYGON);
      var selectQuery = new esri.tasks.Query();
      var fieldsSelectionSymbol = new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([255,255,0,0.5]));
      fieldsSelectionSymbol.setOutline(new esri.symbol.SimpleLineSymbol("dashdot", new dojo.Color([255,0,0]), 2));
      
      selectionToolbar.on("draw-end", function(geometry) {
        selectionToolbar.deactivate();
        selectQuery.geometry = geometry;
 console.log(selectQuery);
        featureLayer.selectFeatures(selectQuery, esri.layers.FeatureLayer.SELECTION_NEW);
        featureLayer.setSelectionSymbol(fieldSelectionSymbol);
        map.addLayer(featureLayer);
      });


I receive this error TypeError: a.spatialReference is undefined when the selectFeatures() is performed and the script stops after that. What could be the problem?

the selectQuery seems to be correct with spatialReference object (wkid: 4326)

Thank you for your help

Outcomes