[OpenLayers-Users] problem using pointRadius computed in context

Zer zer_matt at hotmail.com
Thu Feb 18 11:00:25 EST 2010


Hi,

I'm also fighting with this problem. 

I stared out with this code:

var myStyle = new OpenLayers.Style( {
                    pointRadius :"${radius}",
                    fillColor :'#FFFF00',
                    fillOpacity :0.5,
                    strokeColor :'#FFFFFF',
                    strokeWidth :2,
                    strokeOpacity :0.5
                }, {
                    context : {
                        radius: function(feature) {
                            return Math.min(feature.attributes.radius, 7) +
3;;
                        }
                    }
                });

                var myStyleMap = new OpenLayers.StyleMap( {
                    "default" :myStyle
                });
                
                var wfsSurvey = new OpenLayers.Layer.Vector("Points", {
                    styleMap: myStyleMap,
                    strategies: [new OpenLayers.Strategy.BBOX()],
                    projection: new OpenLayers.Projection("EPSG:4326"),
                    protocol: new OpenLayers.Protocol.WFS({
                        version: "1.1.0",
                        srsName: "EPSG:4326",
                        url: "http://localhost:8080/geoserver/wfs",
                        extractAttributes: true,
                        featureNS :  "http://www.px.org",
                        featureType: "antenna",
                        geometryName: "the_geom",
                        schema:
"http://localhost:8080/geoserver/wfs/DescribeFeatureType?version=1.1.0&
typename=px:antenna"
                    })
                });

If I skip the attribute based styling, the points show up correctly. But as
soon as I try using the radius, points will not show on the map. Or they
will show, but with radius = 0. It seems like the value for the attributes
always will be zero and I get the error "Unexpected value parsing r
attribute." in the Firebug console. 

Struggling with this all day, I decided  to copy some of the code from the
OpenLayers Examples, to see if it works or not. It did not work....

I am using the exact same code as in the OpenLayers StyleMap Example. If I
run the example from the url http://openlayers.org/dev/examples/ , it works
just fine. But when I runt it from my local site,
http://localhost:8080/px/mapjsp, I get the error "Unexpected value parsing r
attribute." in the Firebug console. 

I'm using OpenLayers 2.8 and have tried the code in FF 3.0. FF3.5 and IE 7
with the same negative result. I've checked the GML that's returned from
then WFS-service and everything looks OK. 

I've totally run out of ideas.... Anyone? Suggestions will be highly
appreciable!

Thanks,

ZM 
-- 
View this message in context: http://n2.nabble.com/problem-using-pointRadius-computed-in-context-tp1830106p4592561.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.



More information about the Users mailing list