[OpenLayers-Dev] vector drawFeature bug or by design?

Paul Spencer pspencer at dmsolutions.ca
Wed Jun 17 10:33:11 EDT 2009


I have a question about Layer.Vector.drawFeature when passing a  
style ...

I used this method to update the label of a point with an existing  
style (set directly on the feature) as the measure tool moved by  
calling this.handler.layer.drawFeature(text, {label: newDistance})  
which worked perfectly until the user zoomed using the mouse wheel  
while measuring.  I've since changed this to set text.style.label =  
newDistance; this.handler.layer.drawFeature(text); which works fine.

But this led me to question whether this is by design or a bug.

The relevant docs are:

     /**
      * APIMethod: drawFeature
      * Draw (or redraw) a feature on the layer.  If the optional  
style argument
      * is included, this style will be used.  If no style is  
included, the
      * feature's style will be used.  If the feature doesn't have a  
style,
      * the layer's style will be used.
      *
      * This function is not designed to be used when adding features to
      * the layer (use addFeatures instead). It is meant to be used when
      * the style of a feature has changed, or in some other way needs  
to
      * visually updated *after* it has already been added to a layer.  
You
      * must add the feature to the layer for most layer-related  
events to
      * happen.
      *
      * Parameters:
      * feature - {<OpenLayers.Feature.Vector>}
      * style - {Object} Symbolizer hash or {String} renderIntent
      */

I think if it is design that the feature's style is not updated with  
the passed in style then the docs should be updated to indicate this.   
I can create a ticket for this with a stripped down example if the  
consensus is that it should update the style.  I may even be able to  
provide a patch ...

Paul
__________________________________________

    Paul Spencer
    Chief Technology Officer
    DM Solutions Group Inc
    http://research.dmsolutions.ca/




More information about the Dev mailing list