2012-02-02 51 views
0

當用戶完成繪製多邊形時,多邊形標籤將更新爲計算區域。在多邊形編輯模式下顯示重複的標籤

polygonLayer.styleMap.styles.default.defaultStyle.label = "xxx"; 
polygonLayer.redraw(); 

哪個會實現這個,沒問題。

enter image description here

我把這兩條線,每次多邊形的面積被更新。但是,如果使用編輯控件編輯多邊形,更新的區域將顯示在所有節點上。

enter image description here

而且,如果用戶已經完成編輯並切換到其他節點,一切都恢復正常。當用戶單擊編輯控件時,我試圖將標籤設置爲空字符串,但只隱藏主標籤(中間的標籤),但節點上的標籤仍然存在。

$('.olControlModifyFeatureItemInactive').click(function() { 
      polygonLayer.styleMap.styles.default.defaultStyle.label = ""; 
      polygonLayer.redraw(); 
    }); 

發生了什麼以及如何防止重複顯示的區域值?

回答

1

就以我們的風格地圖看看THIS

您應該能夠建立context,只返回標籤,如果它在編輯模式不是:

var styleMap = new OpenLayers.StyleMap(new OpenLayers.Style({ 
      label: "${getLabel}" 
      // your other symbolizer properties here 
     }, {context: { 
      getLabel: function(feature) { 
       if(!mycontrolIsNotInEditMode) { 
        return feature.attributes.label; 
       } 
      } 
     }} 
    )); 
+1

@Kaung:做我的答案解決你的問題?我在這裏回答了更詳細的問題:http://gis.stackexchange.com/questions/20041/how-to-disable-polygon-label-on-the-vertices-openlayers-in-edit-mode – capdragon 2012-02-13 15:25:09

相關問題