Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a local Geoserver connected to a PostGIS database and a table with an attribute field called "style" which is of data type integer. On the OpenLayers preview of the Geoserver the data is shown and accessible.

The web application I load via an local Apache (XAMPP) server. The same policy origin is considered through an cgi proxy script which is linked within the script.js. with this code line "OpenLayers.ProxyHost = "/cgi-bin/proxy.cgi?url=";". In the proxy script I added localhost for the Apache server and localhost:8080 for the Geoserver.

The problem is that i want to style a WFS over the attribute style, and every style: 1, 2, 3, ... should get an own color and a own checkbox.

For now only the default rule "rule_3" works and I don't know why. Here is the part of the source code:

// Marker Clustering for WFS Layer
var strat = [
    new OpenLayers.Strategy.BBOX(),
    new OpenLayers.Strategy.AnimatedCluster({
        distance: 15,
        animationMethod: OpenLayers.Easing.Expo.easeOut,
        animationDuration: 10
    // new OpenLayers.Strategy.Cluster()

var style = new OpenLayers.Style();

var rule_1 = new OpenLayers.Rule({
    filter : new OpenLayers.Filter.Comparison({
        type : OpenLayers.Filter.Comparison.EQUAL_TO,
        property : 'style',
        value : 1
    symbolizer : {
        fillColor : '#ffffff'

var rule_2 = new OpenLayers.Rule({
    filter : new OpenLayers.Filter.Comparison({
        type : OpenLayers.Filter.Comparison.EQUAL_TO,
        property : 'style',
        value : 2
    symbolizer : {
        fillColor : '#ff00ff'

var rule_3 = new OpenLayers.Rule({
    symbolizer : {
        fillColor : '#ff6600'

style.addRules([rule_1, rule_2, rule_3]); 

var wfsLayer = new OpenLayers.Layer.Vector(
    'Christmas Traditions',
        strategies: strat,
        styleMap: new OpenLayers.StyleMap(style),
        protocol: new OpenLayers.Protocol.WFS({
            version: '1.0.0',
            url: 'http://localhost:8080/geoserver/wfs',
            featurePrefix: 'cite',
            featureType: [
            featureNS: 'http://www.opengeospatial.net/cite',
            //propertyName: ['txt', 'style'],
            srsName: 'EPSG:4326',
            geometryName: 'coords'
    isBaseLayer: false,
    visibility: true,

// Add layers to map object

Current all points have the same color of style rule_3. The dots over Belgium and Netherlands should have an other color. The table "op_god_jul_fts" should have the style of rule_1 and the table "op_vrolij_kerstfeest_fts" should have the style of rule_2.

Perhaps anybody can help me. Thank you and kindly regards!

share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.