2016-07-18 4 views
0

내 응용 프로그램에 편집 가능한 기능 레이어가 2 개 있으며 사용자가 편집하려는 기능 레이어에 따라 적절한 속성 관리자를 연결하려고합니다.2 개의 AttributeInspector에 대해 동일한 InfoWindow 사용하기

응용 프로그램을로드 할 때 두 기능 레이어에 대한 속성 검사기를 만든 다음 사용자가 기능 레이어를 편집하려고 할 때 적절한 특성 검사기를지도의 InfoWindow에 연결합니다.

사용자가 다른 기능 레이어를 편집하려고 시도 할 때까지 모든 것이 잘 작동합니다. infowindow에 다른 속성 검사기를 연결하려고하면 빈 화면이 나타납니다.

는 여기에 내가 뭘하는지 대략의 : 사전에

// AttributeEditor1 for FeatureLayer1 in Class1 

    constructor: function(options) { 
     this.options = lang.mixin(this.options, options); 
     this.map = options.map; 
     this.configureAttributeEditor1(); 
    }, 

    configureAttributeEditor1: function() { 

     this.attributeEditor1 = new AttributeInspector({ 
      layerInfos: layerInfos 
     }, domConstruct.create("div")); 

     // here I add a Save and Delete button and various event handlers 

     this.attributeEditor1.startup(); 

    }, 

    // I call this when I know that the user wants to edit FeatureLayer 1 
    attachEditor1: function() { 
      this.map.infoWindow.setContent(this.attributeEditor1.domNode); 
      this.map.infoWindow.resize(350, 240); 
    }, 

// AttributeEditor2 for FeatureLayer2 in Class2  

    constructor: function(options) { 
     this.options = lang.mixin(this.options, options); 
     this.map = options.map; 
     this.configureAttributeEditor2(); 
    }, 

    configureAttributeEditor2: function() { 

     this.attributeEditor2 = new AttributeInspector({ 
      layerInfos: layerInfos 
     }, domConstruct.create("div")); 

     // here I add a Save and Delete button and various event handlers 

     this.attributeEditor2.startup(); 

    }, 

    // I call this when I know that the user wants to edit FeatureLayer 2 
    attachEditor2: function() { 
      this.map.infoWindow.setContent(this.attributeEditor2.domNode); 
      this.map.infoWindow.resize(350, 240); 
    },  

감사합니다.

+0

AttributeEditor1이 작동하고 AttributeEditor2가 작동하지 않는다는 것을 의미합니까? –

+0

AttributeEditor1은 맵의 InfoWindow 내용을 AttributeEditor2로 바꾸기 전까지 작동합니다. 그런 다음 InfoEditor1을 다시 InfoWindow에 추가하려고하면 빈 상태가됩니다. – awm

답변

0

map.infoWindow.setContent을 사용하여 infoWindow의 내용을 업데이트하면 이전 내용이 삭제 된 다음 새 내용이 업데이트됩니다. 따라서 기본적으로 AttributeInspector1로 정보 창을 업데이트하면 AttributeInspector1이 삭제됩니다.

여러 FeatureLayer에서 작업하는 동안 AttributeInspector을 여러 개 만들 필요가 없습니다. layerInfos 속성은 배열 유형이므로 upd 여러 레이어를 설정할 수 있습니다.

하지만 계층간에 전환 할 때 취해야 할 다른 요구 사항/조치가 있다고 생각합니다. 가장 좋은 방법은 전환 할 때마다 새로운 AttributeInspector를 생성하거나 layerInfos을 업데이트하고 이벤트를 저장 및 삭제하는 것입니다. 이전 저장 W h 제 이벤트 핸들을 제거하십시오.