Select to view content in your preferred language

apply edits for query results

2056
1
05-09-2014 08:06 AM
williamcarr
Frequent Contributor
I am attempting to pass query results to  a function to update the features geometry.

[HTML]       function addGraphic(pt){
          var symbol = new SimpleMarkerSymbol(
            SimpleMarkerSymbol.STYLE_CIRCLE,
            12);
        
          graphic = new Graphic(pt, symbol,null);
          map.graphics.add(graphic);
         
  
         var query = new Query();
  query.where = "OBJECTID = 1";
 
  featureLayer.queryIds(query, function(objectIds) {
    //do something with the objectIds here
  }); 
            
         
          new esri.geometry.Point(pt, map.spatialReference);
         
          var newFeature = new esri.Graphic(geometry, null,null);
           graphic.setGeometry(pt);
         
  
          
                  console.log("prepare to fire");
featureLayer.applyEdits( null,[graphic], null);
          console.log(" Fire on everything!");
          [/HTML]

It runs through the console logs but comes up with a "x.attributes is null" error in the console. I haven't worked much with selectFeatures, so bare with me for any obvious mistakes. Any Ideas?
0 Kudos
1 Reply
williamcarr
Frequent Contributor

          featureLayer.selectFeatures(queryy,FeatureLayer.SELECTION_NEW);

          new esri.geometry.Point(pt, map.spatialReference);

   

           graphic.setGeometry(pt);

          

  //select feature with a static SQL query

          featureLayer.selectFeatures(queryy, FeatureLayer.SELECTION_NEW, function(results) {

            //use the method callback to dig into the results and update its geometry                       

            results[0].geometry = pt;           

            //pass the entire array (in this case one feature) back to the server

            featureLayer.applyEdits(null, results, null);           

            //refresh the layer to make sure the edit was successful

            featureLayer.refresh();

0 Kudos