Geographic Information Systems Asked by anakaine on March 5, 2021
I’m updating a feature in ESR-Leaflet from a feature layer based on a call to a function. What I’m having trouble with is submitting this change to the feature service.
Currently I:
Get the feature based on it’s ObjectID;
Reach into the feature.properties and change “SystemStatus”;
Attempt to submit updateFeatures (and fail).
Code, and error below.
function ChangeStatus(objID){
var retireFeatureID = hotspots.getFeature(objID);
retireFeatureID.feature.properties["SystemStatus"] = "Deleted";
hotspots.updateFeature(retireFeatureID, function (err, response) {
if (err) {
console.log(err);
return;
}
console.log(response);
});
//hotspots.updateFeature(retireFeatureID);
console.log("Updated the status of feature: " + objID);
}
The error I’m receiving is:
{code: 400, message: “Cannot perform operation. Invalid operation
parameters.”, details: Array(2)} code: 400 details: (2) [“‘features’
parameter is invalid”, “Object reference not set to an instance of an
object.”] message: “Cannot perform operation. Invalid operation
parameters.”
I’m not sure what could be causing my issue here.
Suggestions welcome.
The answer was in the updateFeature line. I needed to include '.feature' because otherwise it was sending the entire object, which is not what was expected.
function WriteLog(objID){
var retireFeatureID = hotspots.getFeature(objID);
retireFeatureID.feature.properties["SystemStatus"] = "Deleted";
hotspots.updateFeature(retireFeatureID.feature, function (err, response) {
if (err) {
console.log(err);
return "error";
}
console.log(response);
return "ok";
});
console.log("Updated the status of feature: " + objID);
}
Answered by anakaine on March 5, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP