2017-01-03 13 views
0

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

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

答えて

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)); 

リスナー:https://jsfiddle.net/kreza/jpLj5y4h/2/

:このシオマネキ

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"); 
      }); 
     }) 

チェックアウト

関連する問題