[OpenLayers-Users] Display WFS-Points as markers

Arnd Wippermann arnd.wippermann at web.de
Thu Aug 7 12:51:30 PDT 2014


You can style your features by attributes

see
 
http://openlayers.org/dev/examples/styles-context.html


// create the layer styleMap by giving the default style a context
var colors = ["red", "green", "blue"];
var context = {
    getColor: function(feature) {
        var region = parseInt((feature.geometry.x + 180) / 120);
        return colors[region];
    },
    getSize: function(feature) {
        return feature.attributes["type"] / map.getResolution() * ..703125;
    }
};
var template = {
    pointRadius: "${getSize}", // using context.getSize(feature)
    fillColor: "${getColor}" // using context.getColor(feature)
};
var style = new OpenLayers.Style(template, {context: context});

var layer2 = new OpenLayers.Layer.Vector('Points', {
    styleMap: new OpenLayers.StyleMap(style),
    renderers: renderer
});

Gruß,
Arnd

-----Ursprüngliche Nachricht-----
Von: openlayers-users-bounces at lists.osgeo.org
[mailto:openlayers-users-bounces at lists.osgeo.org] Im Auftrag von sulu
Gesendet: Donnerstag, 7. August 2014 16:54
An: openlayers-users at lists.osgeo.org
Betreff: Re: [OpenLayers-Users] Display WFS-Points as markers

Uh! That looks very promising!

Thanks again Arnd!

Now im wondering if there is a feature like "getElementsByTagName" (found in
an example for GeoRSS)?

That would allow for a dynamic construction for the features (e.g tooltip or
externalGraphic)


Regards,
Andy



--
View this message in context:
http://osgeo-org.1560.x6.nabble.com/Display-WFS-Points-as-markers-tp5154974p
5155439.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
Users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users


---
Diese E-Mail ist frei von Viren und Malware, denn der avast! Antivirus Schutz ist aktiv.
http://www.avast.com



More information about the Users mailing list