[OpenLayers-Users] problem using pointRadius computed in context
sylvie fiat
kiki__fiat at hotmail.com
Mon Mar 16 23:53:27 EDT 2009
Hi,
Thanks for your reply, what I had for the radius value was ${radius} just like in the exemple.
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 :
var myStyle = new OpenLayers.Style( {
pointRadius :"${radius}",
fillColor :defaultFillColor,
fillOpacity :defaultOpacity,
strokeColor :defaultStrokeColor,
strokeWidth :defaultStrokeWidth,
strokeOpacity :defaultStrokeOpacity
}, {
context : {
radius: function(feature) {
return Math.min(feature.attributes.count, 7) + 3;
}
}
});
:
var myStyleMap = new OpenLayers.StyleMap( {
"default" :myStyle
});
new OpenLayers.Layer.Vector(layerStationsName,
{
strategies: [
new OpenLayers.Strategy.Fixed(),
new OpenLayers.Strategy.Cluster()
],
protocol: new OpenLayers.Protocol.HTTP({
url: geoserverUrl+ "/wfs",
params: {
format: SERVICE_WFS,
service: SERVICE_WFS,
request: REQUEST_WFS,
srs: defaultProjection,
VERSION : VERSION,
typename : myLayer,
useBbox: true,
bbox: bounds.toBBOX()
},
format: new OpenLayers.Format.GML()
}),
styleMap: myStyleMap
});
It all work perfectly now, exept from some troubles with IE but that's another thing..
Sylvie
> Subject: RE: [OpenLayers-Users] problem using pointRadius computed in context
> Date: Mon, 16 Mar 2009 08:57:56 -0400
> From: CHRISTOPHER.M.HEIDT at saic.com
> To: lists at dipole-consulting.com; kiki__fiat at hotmail.com
> CC: users at openlayers.org
>
> I don't see what you had before but this wont work because
> pointRadius has to be a number, not a function.
> You can use a function to create the number:
>
> //Styles
> var clusterStyle = new OpenLayers.Style({
> pointRadius: "${radius}",
> fillColor: '#ee9900',
> fillOpacity: 0.8,
> strokeColor: '#ee9900',
> strokeWidth: 1,
> strokeOpacity: 0.8,
> cursor: 'pointer'
> }, {
> context: {
> radius: function(feature) {
>
> if(typeof(feature.attributes.count) != 'undefined')
> {
> return
> Math.min(feature.attributes.count, 7) + 3;
> }
> return 4;
> }
> }
> });
>
> -----Original Message-----
> From: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org]
> On Behalf Of Didrik Pinte
> Sent: Monday, March 16, 2009 6:52 AM
> To: sylvie fiat
> Cc: users at openlayers.org
> Subject: Re: [OpenLayers-Users] problem using pointRadius computed in
> context
>
> On Sun, 2009-03-08 at 23:12 -0700, sylvie fiat wrote:
> > 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
>
> Hi Sylvie,
>
> I guess it was related to some errors in my javascript file. I would
> suggest you to use online javascriptlint to check your syntax and
> identify potential errors.
>
> Didrik
_________________________________________________________________
Téléphonez gratuitement à tous vos proches avec Windows Live Messenger ! Téléchargez-le maintenant !
http://www.windowslive.fr/messenger/1.asp
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090317/03f91cdf/attachment.html
More information about the Users
mailing list