[OpenLayers-Users] problem using pointRadius computed in context

sylvie fiat kiki__fiat at hotmail.com
Mon Mar 9 02:12:36 EDT 2009




Didrik Pinte wrote:
> 
> Hi,
> 
> I'm trying to have a point radius dependant on the scale. Thus I have
> created a Style with a context like this :
> 
>  var holeStyle = new OpenLayers.Style({
>         fillColor: "#FF0000",
>         pointRadius: "${scaledSize}",
>         fillOpacity: 0.8,
>         strokeColor: "#FF0000",
>         strokeWidth: 2,
>         strokeOpacity: 0.8
> 
>     }, {
>         context: {
>             scaledSize: function(feature) {
>                 var res = feature.layer.map.getResolution() ;
> 	      // radius is fixed at 10 meters for the test
>                 var val =  (1 /res) * 10 ;
>                 return val;
>             }
>         }
>     });
> 
> In Firebug, I get the following error when loading the layer : 
> 
> "unexpected value $ parsing r attribute."
> 
> I'm using OpenLayers 2.7.
> 
> Any idea on the cause of the problem ?
> 
> Thanks
> 
> Didrik
> 
> 
>  
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
> 
> 

Hi,

I have the same problem and it's taking me hours, did you figure out what
was the problem ?
I have tried : 
styleMap: new OpenLayers.StyleMap(OpenLayers.Util.applyDefaults(
		        	        {	pointRadius: function(feature){return
Math.min(feature.attributes.count, 7) + 3;},
		        	        	fillColor: "blue", 
		        	        	fillOpacity: 0.5, 
		        	        	strokeColor: "black"},
		        	        OpenLayers.Feature.Vector.style["default"]))

But I got the error:
unexpected value function (feature) { return
Math.min(feature.attributes.count, 7) + 3; } parsing r attribute.

Thanks for any help.
Sylvie
-- 
View this message in context: http://n2.nabble.com/problem-using-pointRadius-computed-in-context-tp1830106p2447662.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.




More information about the Users mailing list