[OpenLayers-Users] Feature Styling

Arnd Wippermann arnd.wippermann at web.de
Wed Oct 8 14:50:52 EDT 2008


How you get your features for styling? I would think, when you update/add
the features to the layer, you have to save the index of the feature array.

This is one way, i change the style of features. 

function changeFeatureStyle(vectorlayer, feature)
{
    var obj     = new OpenLayers.Style();
    
    obj.fillColor     = "red";
    obj.fillOpacity   = 1;
    obj.strokeColor   = "#FF00FF";
    obj.strokeOpacity = 1;
    obj.strokeWidth   = 6;
    obj.strokeLinecap = 'round';
    obj.pointRadius   = 2;
    
    feature.style = obj;
    
    vectorlayer.drawFeature(feature);
}


A second way

function changeFeatureStyle(vectorlayer, feature)
{
    var myStyle = OpenLayers.Util.extend({},
vectorlayer.styleMap.styles["default"].defaultStyle);

    var arrPar  =
["fillColor","fillOpacity","strokeColor","strokeOpacity","strokeWidth","poin
tRadius"];
    var arrPar  = ["red"      , 0.5         ,"blue"       ,1.0
,2.0          ,3.0          ];

    for(key in params)
        myStyle[key] = params[key];

    vectorlayer.styleMap.styles["default"].defaultStyle = myStyle;
    feature.style = myStyle;
    vectorlayer.drawFeature(feature);
}
 
Arnd Wippermann

-----Ursprüngliche Nachricht-----
Von: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] Im
Auftrag von Heidt, Christopher M.
Gesendet: Dienstag, 7. Oktober 2008 22:31
An: users at openlayers.org
Betreff: [OpenLayers-Users] Feature Styling

After an initial load, I run a background process that looks for new/updated
data within my extent.
If I find anything I add/update it to my vector layer.
I want to draw attention to the newly added/updated feature.
I'd really like it to blink but I'd settle for a temporary color change.

I've been messing around with the style maps, but all the examples style
things on load, I need to be able to programmatically get a featureById and
make it "blink" for X seconds.
Any suggestions?
_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users




More information about the Users mailing list