Select to view content in your preferred language

applyEdits for updating data (JS4.4)

2401
12
Jump to solution
09-11-2017 07:13 AM
by Anonymous User
Not applicable

I am having a problem updating a feature layer data using applyEdits function.  I looked at the sample code in applyEdits API reference and Sandbox sample code, but I haven't been able to figure it out how to update the data.  I am only interested in updating existing data attributes.  I would very much appreciate your help.  

require([
  "esri/Map",
  "esri/views/SceneView",
  "esri/layers/FeatureLayer",
  "esri/geometry/Extent",
  'esri/geometry/ScreenPoint',
  'dojo/_base/lang',
  "dojo/on",
  "dojo/dom",
  "dojo/domReady!"
],
  function (
    Map, SceneView, FeatureLayer, Extent, ScreenPoint, lang, on, dom
  ) {
    var lyrUrl = 'https://services1.arcgis.com/aT1T0pU1ZdpuDk1t/arcgis/rest/services/CALO_survey_web/FeatureServer/0';

    var map = new Map({
      basemap: 'satellite'
    });

    var initialExtent = new Extent({
      xmin: -8520399.50094139,
      xmax: -8466523.75224205,
      ymin: 4109431.55147233,
      ymax: 4173688.01969221,
      spatialReference: 102100
    });

    var featureLyr = new FeatureLayer({
      url: lyrUrl
    });
    map.add(featureLyr);

    var sceneView = new SceneView({
      container: 'map',
      map: map,
      extent: initialExtent
    });

    var _onclick = function (evt) {
      var s = new ScreenPoint({
        x: evt.x,
        y: evt.y
      });

    // Updating feature layer data  
    sceneView.hitTest(s).then(picked => {
      console.log(picked);
      if (picked.results[0].graphic) {
        var editFeature = picked.results[0].graphic;
        editFeature.attributes.YearBuilt = '2000';
        console.log('after edit', editFeature);
        var edit = {
          updateFeatures: [editFeature]
        };
        var promise = featureLyr.applyEdits(edit);
        console.log(promise);
      }
    });
  }
  sceneView.on('click', _onclick);
Tags (1)
0 Kudos
12 Replies
by Anonymous User
Not applicable

Hi Robert,

Thank you for the information.  Where can I change the setting?

My layer supported operations are:

ArcGIS Online "Editing" setting is:

Where can I change geometry updates option?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Makiko,

   The first option will allow geometry and attribute updates the second option (that you have selected) only allows attribute updates.

0 Kudos
by Anonymous User
Not applicable

Robert,

Thank you!  It is very important to know about the editing settings!!

0 Kudos