[OpenLayers-Dev] Radius circle doesn't change for Canvas Vector Layer [Canvas.js Class]

Christopher Schmidt crschmidt at metacarta.com
Wed Jun 10 08:44:38 EDT 2009


On Wed, Jun 10, 2009 at 05:06:26AM -0700, geotribu wrote:
> 
> Hi,
> 
> I've noticed that if I use a style with a pointRadius for a vector layer
> (with renderers canvas) the size of the circle doesn't change.
> Indeed the method drawPoint of the Canvas class use the radius properties
> only if the properties drawExternalGraphic is defined.

Please file a ticket with a patch for this issue:

  http://trac.openlayers.org/wiki/FilingTickets

> So I made some little change to the core class Canvas.js and now the radius
> propertie works fine.
> 
> line 256 Actual code :
> this.canvas.arc(pt[0], pt[1], 6, 0, Math.PI*2, true);
> 
> New code :
> var radius = style.pointRadius?style.pointRadius:6;
> this.canvas.arc(pt[0], pt[1], radius, 0, Math.PI*2, true);
> 
> Same things for the condition : style.stroke !== false.
> 
> And for example (user script) :
> 
> var style = new OpenLayers.Style(
> 	{
> 		fillColor: "#ffff00",
>         fillOpacity: 0.5,
>         pointRadius: "${radius}",
> 	    strokeColor: "#ff0000",
>         strokeWidth: 2,
>         strokeOpacity: 0.3
> 	},{		
> 		context: {			
> 		    radius: function(feature) {   
>       		    return (feature.attributes.Population/2000);	
> 		    }
> 	    }
>    }	
> ); 
> 
> var styleMap = new OpenLayers.StyleMap({'default':style, 'select':
> {fillOpacity: 0.7, fillColor: "#ff0000"}});
> 
> vectors = new OpenLayers.Layer.GML( "Reunion city", "./city974.gml",
> 	{
> 			styleMap: styleMap,
> 			renderers: ['Canvas']
> 	}
> ); 
> 
> 
> Best regards
> 
> Arnaud
> 
> -----
> http://geotribu.net Geotribu 
> -- 
> View this message in context: http://n2.nabble.com/Radius-circle-doesn%27t-change-for-Canvas-Vector-Layer--Canvas.js-Class--tp3055191p3055191.html
> Sent from the OpenLayers Dev mailing list archive at Nabble.com.
> 
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev

-- 
Christopher Schmidt
MetaCarta



More information about the Dev mailing list