テンプレートピッカーから新しいフィーチャーを追加する必要がありますが、フィーチャーを保管するより属性インスペクターを表示することはできません。新しいフィーチャーを保存せずに属性インスペクターを表示
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