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(); } }); });
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; });
We're trying to do the same thing. Were you ever able to figure out how to get this working completely?
Thanks.
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.
Shouldn't the process be the same with every type of feature?
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.
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.