显示属性检查器而不保存新功能
问题描述:
需求是从模板选择器添加新功能但未应用它,可以显示属性检查器而不是保存功能。显示属性检查器而不保存新功能
selectedTemplate = templatePicker.getSelected();
然后选择这个selectedTemplate将点放在地图上,而不是通过选择它来打开属性检查器。
selectedTemplate.featureLayer.applyEdits([newGraphic], null, null);
示例代码块:
dojo.connect(drawToolbar, "onDrawEnd", function(geometry) {
//display the editable info window for newly created features
if (map.infoWindow.isShowing) {
map.infoWindow.hide();
}
drawToolbar.deactivate();
var fieldAttributes = layerFieldToAttributes(selectedTemplate.featureLayer.fields);
var newAttributes = dojo.mixin(fieldAttributes, selectedTemplate.template.prototype.attributes);
var newGraphic = new esri.Graphic(geometry, null, newAttributes);
var layerInfos = [{
'featureLayer': selectedTemplate.featureLayer,
'isEditable': true
}];
var attInspector = new esri.dijit.AttributeInspector({
layerInfos: layerInfos
}, dojo.create("div"));
selectedTemplate.featureLayer.applyEdits([newGraphic], null, null, function() {
var screenPoint = map.toScreen(getInfoWindowPositionPoint(newGraphic));
map.infoWindow.setContent(attInspector.domNode);
map.infoWindow.resize(325, 185);
map.infoWindow.show(screenPoint, map.getInfoWindowAnchor(screenPoint));
templatePicker.clearSelection();
});
dojo.connect(attInspector, "onAttributeChange", function(feature, fieldName, newFieldValue) {
feature.attributes[fieldName] = newFieldValue;
feature.getLayer().applyEdits(null, [feature], null);
});
dojo.connect(attInspector, "onDelete", function(feature) {
feature.getLayer().applyEdits(null, null, [feature]);
map.infoWindow.hide();
});
});
}
我想我的第一个客户端添加功能属性和(保存&适用)它。
任何帮助,将不胜感激。
下面是示例项目:https://www.dropbox.com/s/fh71g1k9nsa70nq/index-2.html.zip?dl=0
答
我不认为你可以做到这一点的AttributeInspector,尝试创建将有选择保存和删除/取消,节省火灾时applyEdits自定义弹出,当点击删除,删除等。
内容:
var content = "<input id='text1'></input> </br>" +
"<input id='text1'></input> </br>" + "<button id='submit'>Submit</button>" + "<button id='delete'>Delete</button>"
/*
var attInspector = new AttributeInspector({
layerInfos: layerInfos
}, dojo.create("div"));
*/
map.infoWindow.setTitle(selectedTemplate.featureLayer.name);
map.infoWindow.setContent(content);
map.infoWindow.resize(350, 240);
map.infoWindow.show(evt.geometry, map.getInfoWindowAnchor(evt.geometry));
监听器:
on(map.infoWindow, "show", function() {
on(dom.byId("submit"), "click", function() {
alert("I should be saving");
});
on(dom.byId("delete"), "click", function() {
alert("I should be deleting");
});
})