2012-02-02 78 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

相关问题