Attribute Inspector for Points editing

1397
6
04-22-2014 09:38 AM
BrandonIves
New Contributor
I am attempting to get an application working where editors can click on a point feature and edit a form. I need the form to have a save button that when clicked will apply the edits to the feature.

I am selecting the point/s using an envelope. Is there a way I can tell what feature I need to apply the edits to on my save click event? I would like to store the edits to a feature as fields are changed and then only save the edits to the feature class with the save button.

I am trying to use this example to understand the edit saving and then the feature save. Attribute Inspector

Here is what I am working with right now. I am grabbing the point features within an envelope:

function initEditor() {
          var featureLayer = layersFS[1].layer;            

      var selectQuery = new Query();
      map.on("click", function (evt) {

          var centerPoint = new esri.geometry.Point
           (evt.mapPoint.x, evt.mapPoint.y, evt.mapPoint.spatialReference);
          var mapWidth = map.extent.getWidth();

          //Divide width in map units by width in pixels
          var pixelWidth = mapWidth / map.width;

          //Calculate a 10 pixel envelope width (5 pixel tolerance on each side)
          var tolerance = 10 * pixelWidth;

          //build query filter
          query = new esri.tasks.Query();
          query.returnGeometry = true;
          query.outFields = ["*"];

          //Build tolerance envelope and set it as the query geometry
          var queryExtent = new esri.geometry.Extent
                  (1, 1, tolerance, tolerance, evt.mapPoint.spatialReference);
          query.geometry = queryExtent.centerAt(centerPoint);
          featureLayer.selectFeatures(query, FeatureLayer.SELECTION_NEW, function (features) {
              if (features.length > 0) {
                  //store the current feature
                  for (var i = 0; i < features.length; i++) {
                      updateFeatures.push(features);                          
                  }
                  //map.infoWindow.setTitle(features[0].getLayer().name);
                  map.infoWindow.show(evt.screenPoint, map.getInfoWindowAnchor(evt.screenPoint));
              } else {
                  map.infoWindow.hide();
              }
          });
      });


Then I am planning to update the specific feature with the save button:

saveButton.on("click", function () {
          //need to figure out how to get the current feature with the save click, 
          //the envelope may return 1 to many records and I need the current feature
          updateFeatures.forEach(function(entry) {
          updateFeature.getLayer().applyEdits(null, [updateFeature], null);            
          }
       )});

      ///////Need to apply similar logic as save button click but this will update the current feature in the updateFeatures[]
      attInspector.on("attribute-change", function (evt) {
          //store the updates to apply when the save button is clicked 
          updateFeature.attributes[evt.fieldName] = evt.fieldValue;
      });


What is the best way to determine what my current feature is in the info window that is being edited?

Thanks for any advice!
0 Kudos
6 Replies
JenniferWeand
New Contributor

We're trying to do the same thing.  Were you ever able to figure out how to get this working completely?

Thanks.

0 Kudos
TimWitt2
MVP Alum
0 Kudos
JenniferWeand
New Contributor

I'm trying to use the Attribute Inspector with Lines and Points. I was able to use that example to query polygons, but have so far been unsuccessful in querying lines and points for the attribute inspector.

0 Kudos
TimWitt2
MVP Alum

Shouldn't the process be the same with every type of feature?

0 Kudos
williamcarr
Occasional Contributor II

function findWells(evt) {

        var selectionQuery = new esri.tasks.Query();

        var tol = map.extent.getWidth()/map.width * 5;

        var x = evt.mapPoint.x;

        var y = evt.mapPoint.y;

        var queryExtent = new esri.geometry.Extent(x-tol,y-tol,x+tol,y+tol,evt.mapPoint.spatialReference);

        selectionQuery.geometry = queryExtent;

        wellFeatureLayer.selectFeatures(selectionQuery,esri.layers.FeatureLayer.SELECTION_NEW);

      };

This is what I use to pull points and lines.

0 Kudos
JenniferWeand
New Contributor

Thanks, William. That helped.

This Multiple Attribute Inspectors | ArcGIS API for JavaScript‌ also helped with figuring out how to get the AI to handle the different layers. 

0 Kudos