显示属性检查器而不保存新功能

时间:2017-01-03 10:10:13

标签: javascript arcgis arcgis-js-api

要求是从模板选择器添加新功能但不应用它,我可以显示属性检查器而不是保存功能。

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

1 个答案:

答案 0 :(得分:0)

我不认为你可以使用AttributeInspector做到这一点,尝试创建一个自定义弹出窗口,其中包含保存和删除/取消的选项,当保存激活applyEdits时,单击删除,删除等等。

内容:

check_every

监听器:

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/