<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
</style>
</head>
<body class='hmmessage'>
Hi,<br><br>Thanks for your reply, what I had for the radius value was ${radius} just like in the exemple.<br><br>I figured out that my problem was not in the radius definition itself but in the layer definition, first my style definition was at the wrong place then I had to define the styleMap out of the vector and my style out of the styleMap and it worked :<br><br>var myStyle = new OpenLayers.Style( {<br> pointRadius :"${radius}",<br> fillColor :defaultFillColor,<br> fillOpacity :defaultOpacity,<br> strokeColor :defaultStrokeColor,<br> strokeWidth :defaultStrokeWidth,<br> strokeOpacity :defaultStrokeOpacity<br>}, {<br> context : {<br> radius: function(feature) {<br> return Math.min(feature.attributes.count, 7) + 3;<br> }<br> }<br>});<br>:<br><br>var myStyleMap = new OpenLayers.StyleMap( {<br> "default" :myStyle<br>});<br><br>new OpenLayers.Layer.Vector(layerStationsName,<br> {<br> strategies: [<br> new OpenLayers.Strategy.Fixed(),<br> new OpenLayers.Strategy.Cluster() <br> ],<br> protocol: new OpenLayers.Protocol.HTTP({<br> url: geoserverUrl+ "/wfs",<br> params: {<br> format: SERVICE_WFS,<br> service: SERVICE_WFS,<br> request: REQUEST_WFS,<br> srs: defaultProjection, <br> VERSION : VERSION,<br> typename : myLayer,<br> useBbox: true,<br> bbox: bounds.toBBOX()<br> },<br> format: new OpenLayers.Format.GML() <br> }),<br> styleMap: myStyleMap<br> });<br><br>It all work perfectly now, exept from some troubles with IE but that's another thing..<br><br>Sylvie<br><br>> Subject: RE: [OpenLayers-Users] problem using pointRadius computed in        context<br>> Date: Mon, 16 Mar 2009 08:57:56 -0400<br>> From: CHRISTOPHER.M.HEIDT@saic.com<br>> To: lists@dipole-consulting.com; kiki__fiat@hotmail.com<br>> CC: users@openlayers.org<br>> <br>> I don't see what you had before but this wont work because<br>> pointRadius has to be a number, not a function.<br>> You can use a function to create the number:<br>> <br>> //Styles<br>>         var clusterStyle = new OpenLayers.Style({<br>> pointRadius: "${radius}",<br>> fillColor: '#ee9900',<br>> fillOpacity: 0.8,<br>> strokeColor: '#ee9900',<br>> strokeWidth: 1,<br>> strokeOpacity: 0.8,<br>>                 cursor: 'pointer'<br>> }, {<br>> context: {<br>> radius: function(feature) {<br>>         <br>> if(typeof(feature.attributes.count) != 'undefined')<br>>                                         {<br>>                                                 return<br>> Math.min(feature.attributes.count, 7) + 3;<br>>                                         }<br>>                                         return 4;<br>> }<br>> }<br>> }); <br>> <br>> -----Original Message-----<br>> From: users-bounces@openlayers.org [mailto:users-bounces@openlayers.org]<br>> On Behalf Of Didrik Pinte<br>> Sent: Monday, March 16, 2009 6:52 AM<br>> To: sylvie fiat<br>> Cc: users@openlayers.org<br>> Subject: Re: [OpenLayers-Users] problem using pointRadius computed in<br>> context<br>> <br>> On Sun, 2009-03-08 at 23:12 -0700, sylvie fiat wrote:<br>> > Hi,<br>> > <br>> > I have the same problem and it's taking me hours, did you figure out <br>> > what was the problem ?<br>> > I have tried : <br>> > styleMap: new OpenLayers.StyleMap(OpenLayers.Util.applyDefaults(<br>> >                           {        pointRadius:<br>> function(feature){return<br>> > Math.min(feature.attributes.count, 7) + 3;},<br>> >                                   fillColor: "blue", <br>> >                                   fillOpacity: 0.5, <br>> >                                   strokeColor: "black"},<br>> ><br>> OpenLayers.Feature.Vector.style["default"]))<br>> > <br>> > But I got the error:<br>> > unexpected value function (feature) { return <br>> > Math.min(feature.attributes.count, 7) + 3; } parsing r attribute.<br>> > <br>> > Thanks for any help.<br>> > Sylvie<br>> <br>> Hi Sylvie,<br>> <br>> I guess it was related to some errors in my javascript file. I would<br>> suggest you to use online javascriptlint to check your syntax and<br>> identify potential errors. <br>> <br>> Didrik<br><br /><hr />Discutez sur Messenger oł que vous soyez ! <a href='http://www.messengersurvotremobile.com/' target='_new'>Mettez Messenger sur votre mobile !</a></body>
</html>