Error 400 (Invalid or missing input parameters) on a selectFeatures()

11650
13
01-20-2014 06:46 AM
MaxDemars
New Contributor III
Hi,

I use a draw tool to select features like this:

    function initSelectToolbar(map) {
      featureLayer = new esri.layers.FeatureLayer("http://localhost:6080/arcgis/rest/services/carte1/MapServer/0", {
        mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
        outFields: ["*"]
      });

      console.log(featureLayer);
      selectionToolbar = new esri.toolbars.Draw(map);
      selectionToolbar.activate(esri.toolbars.Draw.FREEHAND_POLYGON);
      var selectQuery = new esri.tasks.Query();
      var fieldsSelectionSymbol = new esri.symbol.SimpleMarkerSymbol(
        esri.symbol.SimpleMarkerSymbol.STYLE_DIAMOND,
        20,
        new esri.symbol.SimpleLineSymbol(
          esri.symbol.SimpleLineSymbol.STYLE_SOLID,
          new dojo.Color([88,116,152]), 2
        ),
        new dojo.Color([88,116,152,0.45])
      );

      selectionToolbar.on("draw-end", function(geometry) {
        selectionToolbar.deactivate();
        selectQuery.geometry = geometry;
        selectQuery.geometry.spatialReference = sr;
        featureLayer.selectFeatures(selectQuery, esri.layers.FeatureLayer.SELECTION_NEW);
        featureLayer.setSelectionSymbol(fieldsSelectionSymbol);
        map.addLayer(featureLayer);
      });
    }


I receive an error 400 Missing Parameters when selectFeatures() is performed.

What could be the error?

Thank you for your help
0 Kudos
13 Replies
JamieSimko
New Contributor III
No, I don't think that is normal. See my previous post (I think you may have missed it); it makes note of that.
0 Kudos
JohnathanBarclay
Occasional Contributor
It's not true that you need to use a FeatureServer url with FeatureLayer; MapServer works fine.

Have you tried adding:

console.log(selectQuery.geometry)


before you run the selectFeatures method?
0 Kudos
JamieSimko
New Contributor III
It's not true that you need to use a FeatureServer url with FeatureLayer; MapServer works fine.


JGBarclay is right, I wasn't aware of this but it makes sense if you don't need to do any editing.
0 Kudos
MaxDemars
New Contributor III
Hi JGBarclay

console.log(selectQuery.geometry) returns an object but I am not sure if it is valid.

Object {geometry: Object, target: Object}
geometry: Object
     _centroid: null
     _extent: null
     _ring: 0
  rings: Array[1]
    0: Array[11]
     0: Array[2]
       0: -69.33183267437701
       1: 45.45381694926503
       length: 2
       __proto__: Array[0]
     1: Array[2]
     2: Array[2]
     3: Array[2]
     4: Array[2]
     5: Array[2]
     6: Array[2]
     7: Array[2]
     8: Array[2]
     9: Array[2]
     10: Array[2]
      length: 11
      __proto__: Array[0]
      length: 1
      __proto__: Array[0]
     spatialReference: Object
       latestWkid: 4326
       wkid: 4326
       __proto__: Object
     type: "polygon"
      __proto__: Object
  spatialReference: Object
    wkid: 4326
    __proto__: Object
  target: Object
    __proto__: Object
0 Kudos