AnsweredAssumed Answered

How to allow updating attributes automatically and manually with editor widget?

Question asked by christinawong on Aug 30, 2018
Latest reply on Aug 30, 2018 by rscheitlin

Hello, I'm trying to create an editing web map that will automatically update the coordinates of an added/moved point and also allow manual edits to other attributes. I was able to get the coordinates to update, based on this code I found on stack exchange.

 

Below is what I have in my HTML and seems to work whenever I add or move a point.

dojo.forEach(featLayers, function(feature) {
feature.on("before-apply-edits", updateCoordinates);
});

 

function updateCoordinates(evt) {
var toAdd = evt.adds;
dojo.forEach(toAdd, function(add) {
add.attributes.point_y = add.geometry.getLatitude();
add.attributes.point_x = add.geometry.getLongitude();
});

var toUpdate = evt.updates;
dojo.forEach(toUpdate, function(update) {
update.attributes.point_y = update.geometry.getLatitude();
update.attributes.point_x = update.geometry.getLongitude();
});
}

 

However, when I manually type in text for another attribute that is entered during the editing, I get these error messages in the console as shown in the attached graphic. Line #305 in the console refers to the above code line #10 update.attributes.point_y = update.geometry.getLatitude();

 

The attributes I manually update are not saved most of the time.

 

Any help is much appreciated!

Attachments

Outcomes