Reputation: 587
When the user has finished drawing polygons, the polygon label will be update with the calculated area.
polygonLayer.styleMap.styles.default.defaultStyle.label = "xxx";
polygonLayer.redraw();
which will achieve this, no problem.
I call this two lines everytime the area of the polygon is updated. However, if I edit the polygon with edit control, the updated area will be displayed on all the nodes.
And if the user has finished editing and switch to other nodes, everything went back to normal. I have tried setting the labels to empty strings when the user clicks on the editing control but that only hides the main label (the one in the center), but the labels on the nodes are still there.
$('.olControlModifyFeatureItemInactive').click(function() {
polygonLayer.styleMap.styles.default.defaultStyle.label = "";
polygonLayer.redraw();
});
What is happening there and how do I prevent duplicated area values from showing up?
Upvotes: 0
Views: 754
Reputation: 14899
Take a look at THIS
You should be able to setup context
on our style map and only return the label if it's NOT in edit mode:
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;
}
}
}}
));
Upvotes: 1