[OpenLayers-Users] 'undefined' at vertices while editingvectorlayer

Arnd Wippermann arnd.wippermann at web.de
Tue Aug 31 13:57:26 EDT 2010


Hi,

The features have no values = "undefined", but a status of "undefined". So
your comparison can not work.

The only idea I have, is to set i.e an attribute "show"="yes" for features,
that should be labeled. And add the below rule:

var PolygonSymbolizer = { fillColor: "${color}",
                          fillOpacity: 0.5,
                          strokeColor: "${color}",
                          strokeOpacity: 0.8,
                          strokeWidth: 4,
                          pointRadius: 6
                        };

var TextSymbolizer = { label: "${name}",
                       fontColor: "#000000",
                       fontSize: "24px",
                       fontFamily: "Courier New, monospace",
                       fontWeight: "bold"
                     };

var Symbolizer = { Polygon : PolygonSymbolizer, Text : TextSymbolizer};

var rules = [ new OpenLayers.Rule({
                  filter: new OpenLayers.Filter.Comparison({
                    type: OpenLayers.Filter.Comparison.EQUAL_TO,
                    property: "show",
                    value: "yes",
                  }),
                  symbolizer: Symbolizer,
                  elseFilter: false
              }),
              new OpenLayers.Rule({
                  symbolizer: {Text:{
                    label: ""
                  }},
                  elseFilter: true
              })
];
_aktLayer.styleMap.styles["default"].addRules(rules);
_aktLayer.redraw();

 
The other way are to patch OpenLayers.Control.ModifyFeature.collectVertices
(row 634), that an other style will used for the vertices instead of the
default style.

Original line : vertex = new OpenLayers.Feature.Vector(component);
Patched line : vertex = new OpenLayers.Feature.Vector(component, null,
OpenLayers.Feature.Vector.style['select']);

But I'm not sure, if there are other and better ways to accomplish the task.

Arnd

-----Ursprüngliche Nachricht-----
Von: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] Im
Auftrag von Alex Dean
Gesendet: Dienstag, 31. August 2010 16:10
An: users at openlayers.org
Betreff: Re: [OpenLayers-Users] 'undefined' at vertices while
editingvectorlayer

Thanks for the help.  I see that the 'default' style is being used to render
the vertices, but I still don't understand how to prevent 'undefined' labels
from being applied to them.

I did look at the code for
OpenLayers.Control.ModifyFeature.collectVertices, but I'm not sure what to
do with it.  It doesn't appear that styling is applied at this point, except
in the case of virtual vertices (which have the control's virtualStyle
applied).  Could you explain a little more what you mean here?

I've also been trying to apply a rule like this:

new OpenLayers.Rule({
   filter: new OpenLayers.Filter.Comparison({
     type: OpenLayers.Filter.Comparison.EQUAL_TO,
     property: "name",
     value: undefined,
   }),
   symbolizer: {
     label: ""
   }
});

What do you think of this approach?  It seems like this might solve my
problem, but I'm having some difficulties getting it applied properly.

thanks,
alex

On Aug 30, 2010, at 11:55 AM, Arnd Wippermann wrote:

> Hi,
>
> Most likely it's the label, what's undefined.
>
> OpenLayers use the default style for rendering the vertices and in 
> this context the attribute 'name' isn't defined. Were your color 
> undefined, then the renderer would use black to render the features, 
> but doesn't display a text message.
>
> If you want to change this behaviour, then look at the function 
> OpenLayers.Control.ModifyFeature.collectVertices
>
> Arnd
>
> -----Ursprüngliche Nachricht-----
> Von: users-bounces at openlayers.org [mailto:users- 
> bounces at openlayers.org] Im Auftrag von Alex Dean
> Gesendet: Montag, 30. August 2010 16:10
> An: users at openlayers.org
> Betreff: [OpenLayers-Users] 'undefined' at vertices while editing 
> vectorlayer
>
> When I define my own styling for a vector layer, I see 'undefined'  
> at the
> vertices while editing a feature.
>
> Screenshot of feature when I'm not editing it :
> http://skitch.com/alexdean/dwe1i/without-editing
> Screenshot of feature while editing:
> http://skitch.com/alexdean/dwe14/with-editing
>
> Using Firebug/Firefox, I can see the following SVG for one vertex.
> <circle id="OpenLayers.Geometry.Point_146" cx="827.6666666759318"
> cy="79.09283407817736" r="6" fill="undefined" fill-opacity="0.5"
> stroke="undefined" stroke-opacity="0.8" stroke-width="4" stroke- 
> linecap="round" stroke-linejoin="round" stroke-dasharray="none"/>
>
> I see 'undefined' is the value use for 'fill' and 'stroke', so I 
> imagine one of these may be the problem.  I can't figure out what keys 
> I need to define in my style objects to resolve this problem.  Can 
> someone help?
>
> This is how I've defined the layer:
>
> wfs = new OpenLayers.Layer.Vector("Regions", {
>   styleMap: new OpenLayers.StyleMap( {
>     'default':{
>       label: "${name}",
>       fillColor: "${color}",
>       fillOpacity: 0.5,
>       strokeColor: "${color}",
>       strokeOpacity: 0.8,
>       strokeWidth: 4,
>       pointRadius: 6,
>       fontColor: "#000000",
>       fontSize: "24px",
>       fontFamily: "Courier New, monospace",
>       fontWeight: "bold"
>     }
>   })
> });
>
> The edit control is defined as follows:
>
> var edit = new OpenLayers.Control.ModifyFeature(wfs, {
>   title: "Edit Existing Region",
>   displayClass: "olControlModifyFeature"
> });
>
> As you can see in the screenshots, the 'color' attribute (eg "$
> {color}") has been set for the feature in question and is rendered 
> correctly when I'm not editing the feature.  The 'undefined' text only 
> appears when I edit the feature using an instance of 
> OpenLayers.Control.ModifyFeature.
>
> thanks,
> alex
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
>

_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users




More information about the Users mailing list