我正在尝试通过rest和json更改来自arcgis服务的功能的信息。我已经创建了一个将被调用的函数,但结果让我不知道该怎么做。
我也在使用 openlayers3,我知道它有功能 feature.setProperties 但我不确定如何实际将其应用于服务。我已经检查了这个例子来理解它: http://openlayers.org/en/latest/examples/vector-esri-edit.html?q=arcgis 但遗憾的是我没有,因为我无法创建有效负载变量。
但如果有办法用 openlayers3 做到这一点,我会更高兴。
我使用的代码是:
export function changeFeature(feature) {
var str = {};
str = feature.getProperties();
for (var s in str) {
if (typeof str[s] === 'object') {
} else {
str[s] = document.getElementById(''+s + '1').value;
feature[s] = document.getElementById(''+s + '1').value;
}
};
console.log(str);
$.ajax({
type: "POST",
url: "http://192.168.216.56:6080/arcgis/rest/services/test/MyMapService/FeatureServer/0/applyEdits",
data: str,
contentType: "application/json; charset=utf-8",
dataType: "json",
processData: true,
success: function (data, status, jqXHR) {
alert("success..." + data);
},
error: function (xhr) {
alert(xhr.responseText);
}
});
}
控制台会给我这个:
Object { geometry: Object,
objectid: "56400",
relcp86d_: "0",
relcp86d_i: "564",
symbol: "4",
polygonid: "0",
scale: "1",
angle: "0",
omschrijvi: "Rosmolen" }
看起来不错,但随后它抛出了这个错误:
TypeError: event is undefined[Meer info]
最佳答案
这里是使用Applyedit的Esri文档:http://help.arcgis.com/en/arcgisserver/10.0/apis/rest/fsedits.html
因此要更新功能,您必须发送包含两个对象的 json :
其中一个是几何图形,其中包含要素的 X、Y 坐标
另一个是属性,用OBJECTID键值对,和其他属性对来更新。
关于javascript - 使用 jquery/javascript 通过 Rest 和 json 编辑 ArcGIS 服务中的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41285644/