In my application I can click on a point or add a point to a sign or support layer, but my support layer does not appear to apply the edits and my sign layer does not appear to apply edits or add graphics. I also have this project on github at: csergent45/streetSigns · GitHub and the file that I am working on is in app/main.js Any ideas on this Tom Wayson ? I see the edits in the console.log, but they don't apply right after that.
Here is my code for both layers:
// temporarily show alert when starting edits
// and then start listening for a map click
var startCaptureRequest = function (severity) {
var listener;
// NOTE: once user has clicked "x" to dismiss
// this alert, it will no longer show up
domStyle.set(app.startEditAlert, "display", "");
setTimeout(function () {
domStyle.set(app.startEditAlert, "display", "none");
}, 3000);
// save map point in app global and
listener = app.map.on("click", function (e) {
listener.remove();
// save map point in app global and
// show form to collect incident report
app.currentGeometry = e.mapPoint;
/* Show signs form */
if (severity === "0") {
document.getElementById("signForm").reset();
app.attributesSignModal.modal("show");
/* Enter your domain item and then the element to populate */
populateSelect("BACKING", "backing","sign");
populateSelect("VISIBILITY", "visibility","sign");
populateSelect("CONDITION_", "condition","sign");
populateSelect("COLOR1", "color1","sign");
populateSelect("DELINEATOR", "delineator","sign");
populateSelect("ILLUM", "illum","sign");
populateSelect("ATTACHTYPE", "attachType","sign");
populateSelect("ATTACHLOC", "attachLoc","sign");
populateSelect("SITEOBS", "siteObs","sign");
populateSelect("SIGNSHAPE", "signShape","sign");
populateSelect("COLOR2", "color2","sign");
populateSelect("MUTCD", "mutcd","sign");
/* Show supports form */
} else if (severity === "1") {
document.getElementById("supportForm").reset();
app.attributesModal.modal("show");
/* Enter your domain item and then the element to populate */
populateSelect("TYPE", "type","support");
populateSelect("SIZE_", "size","support");
populateSelect("MATERIAL", "material","support");
populateSelect("BASE", "base","support");
populateSelect("RATING", "rating","support");
}
});
};
var stopCaptureRequest = function () {
app.currentGeometry = null;
};
// get attributes from form and submit
var submitSupports = function () {
alert(domClass.contains("attributesModal", "in"));
var attributes = {
// TODO: not sure if this is needed
//requestreceived: null
};
var currentDate = new Date(); // current date is defined but never used.
var graphic;
graphic = new Graphic(app.currentGeometry);
query("#attributesModal input, #attributesModal select, #attributesModal textarea").forEach(function (formInput) {
attributes[formInput.name] = formInput.value;
});
// Form Validation - ensures that the values for the database are here if left blank
if ((attributes.supportId === undefined) || (attributes.supportId === "")) {
attributes.supportId = null;
}
if ((attributes.dateInv === undefined) || (attributes.dateInv === "")) {
attributes.dateInv = null;
}
if ((attributes.addrCode === undefined) || (attributes.addrCode === "")) {
attributes.addrCode = null;
}
graphic.setAttributes(attributes);
stopCaptureRequest();
//console.log(attributes);
app.supportLayer.applyEdits([graphic], null, null).then(function (response) {
console.log(response);
});
};
// get sign attributes from form and submit
var submitSigns = function () {
alert(domClass.contains("attributesSignModal", "in"));
var attributes = {
// TODO: not sure if this is needed
//requestreceived: null
};
var currentDate = new Date(); // current date is defined but never used.
var graphic;
graphic = new Graphic(app.currentGeometry);
query("#attributesSignModal input, #attributesSignModal select, #attributesSignModal textarea").forEach(function(formInput) {
attributes[formInput.name] = formInput.value;
});
// Form validation - ensures that the values for the data are here if left blank
if ((attributes.installed === undefined)|| (attributes.installed === "")) {
attributes.installed = null;
}
if ((attributes.signId === undefined) || (attributes.signId === "")) {
attributes.signId = null;
}
if ((attributes.supportId === undefined) || (attributes.supportId === "")) {
attributes.supportId = null;
}
graphic.setAttributes(attributes);
stopCaptureRequest();
//console.log(attributes);
app.signLayer.applyEdits([graphic], null, null).then(function (response) {
console.log(response);
});
};
Solved! Go to Solution.
Try calling refresh() on the layers at the same lines where you call the console.log() statements above.
I once had this issue because I had a definition query on the layer I was editing, so although the edits were added they were not drawn in the map...thought it worth mentioning.
When I tagged you, I had an incident with support and originally was having a difficult time with it. They have told me since, that my code is refreshing the page on submit; not sure why. If I have a solution I will post it later. I just don't know what might cause a page to refresh without that code in JavaScript.
I realized one other thing, in the function:
I had to modify some code for the order of my data being entered but that worked. Thanks!