Hi,

It should work.

The styleMap of the layer is used, when new features are added to the layer.
If your attributes match the rules in your stylemap, then the features
should displayed in that way without any further tasks.

Arnd


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Heiner
Lamprecht
Gesendet: Dienstag, 9. November 2010 22:04
An: [email protected]
Betreff: [OpenLayers-Users] Using style depending on feature attributes

Dear,

I'm quite new to OpenLayers, started with some small tests last weekend.
So, please forgive me, if I ask some stupid questions ;-)

At the moment, I want to change the style of a feature according to some
attribute values.  I looked into the examples (like style-rules.html and
styles-rotation.html), and it looks quite good.  My only problem is:  How to
use this with dynamically loaded data.

If I create the features like in the examples (JS-Code in the page) and add
them to the layer ("vector.addFeatures(features);"), it works.  But I would
like to load the features from a server, using the text format
(tab-seperated):

    var vector = new OpenLayers.Layer.Vector("Points", {
        strategies: [new OpenLayers.Strategy.Fixed()],
        styleMap: new OpenLayers.StyleMap(style),
        protocol: new OpenLayers.Protocol.HTTP({
            url: "/MapTest/FeatureServlet",
            format: new OpenLayers.Format.Text()
        })
    });

I can use the feature attributes f.e. in a layer, so in general, they are
created correctly.

Any hints what is going wrong?  Any additional info needed?


Best regards,


    Heiner

_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to