[OpenLayers-Users] StyleMap, Style and Rules not working

Casper Børgesen cbo at le34.dk
Mon Dec 21 10:36:26 EST 2009


Looking at various examples of how to use styles in OpenLayers, we have built the following:
 
var Layer_AddressWebService_1 = new OpenLayers.Layer.Vector(
    "AddressWebService_1",
    {
        styleMap: new OpenLayers.StyleMap(
        {
            "default": new OpenLayers.Style(
            {
                rules: 
                [
                    new OpenLayers.Rule(
                    {
                        symbolizer:
                        {
                            "Point":
                            {
                                pointRadius: 4,
                                graphicName: 'square',
                                fillColor: 'blue',
                                fillOpacity: 1,
                                strokeWidth: 1,
                                strokeOpacity: 1,
                                strokeColor: '#0000FF'
                            }
                        }
                    })
                ]
            })
        })
    }, {
        displayInLayerSwitcher: false,
        isBaseLayer: false
    }
);
 
We think this should resemble and hopefully be functionally identical to:
 
var awsSymbolizer = {
    "Point": {
        pointRadius: 4,
        graphicName: "square",
        fillColor: "blue",
        fillOpacity: 1,
        strokeWidth: 1,
        strokeOpacity: 1,
        strokeColor: "#0000FF"
     }
};
 
var awsStyle = new OpenLayers.Style();
awsStyle.addRules([new OpenLayers.Rule({symbolizer: awsSymbolizer})]);
var awsStyleMap = new OpenLayers.StyleMap({"default": awsStyle}); 
var Layer_AddressWebService_1 = new OpenLayers.Layer.Vector("AddressWebService_1",
{
    styleMap: awsStyleMap
}, {
    displayInLayerSwitcher: false, 
    isBaseLayer: false
});

But it is not. When using the latter, points are visualised fine, but using the first part, results in nothing. The problem lies around the rules. Can anyone tell me what the major difference is?
 
 
Regards Casper
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20091221/37f6bc9a/attachment.html


More information about the Users mailing list