[OpenLayers-Users] attribute based styles

Puneet Kishor punk.kish at gmail.com
Fri Sep 23 18:15:12 EDT 2011


My data look like so 

    "e" : {
        "features" : [
             {
                "geometry" : {
                   "coordinates" : [
                      -116.6522,
                      34.0985
                   ],
                   "type" : "Point"
                },
                "type" : "Feature",
                "properties" : {
                   "radius" : 20,
                   "opacity" : 0.3
                }
             },
             {
                "geometry" : {
                   "coordinates" : [
                      -126.5362,
                      36.0933
                   ],
                   "type" : "Point"
                },
                "type" : "Feature",
                "properties" : {
                   "radius" : 10,
                   "opacity" : 0.5
                }
             }
        ]
    }

and the layer definition is 

    var lyr = new OpenLayers.Layer.Vector(
        "a layer", {
            style: {
                "strokeWidth": 1, 
                "strokeColor": "#ff0000", 
                "fillColor": "#ff0000", 
                "fillOpacity": "${opacity}", 
                "pointRadius": "${radius}"
            }
        }
    );
    
I was expecting the points to be rendered with the radius and opacity values for each feature. But not so. What am I doing wrong?

--
Puneet Kishor


More information about the Users mailing list