Ticket #2126 (closed bug: fixed)

Opened 4 years ago

Last modified 3 years ago

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

Reported by: arnaud Owned by: crschmidt
Priority: minor Milestone: 2.9 Release
Component: Renderer.Canvas Version: SVN
Keywords: Cc:
State: Complete

Description

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.

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

}

);

Attachments

Canvas.js Download (16.3 KB) - added by arnaud 4 years ago.
Canvas-drawPointRadius.patch Download (1.0 KB) - added by gregers 4 years ago.
Support radius for Canvas.drawPoint

Change History

Changed 4 years ago by arnaud

Changed 4 years ago by arnaud

  • owner set to crschmidt
  • component changed from general to Renderer.Canvas

Changed 4 years ago by arnaud

  • keywords canvans added; canvasn removed

Changed 4 years ago by arnaud

  • keywords canvas added; canvans removed

Changed 4 years ago by crschmidt

  • milestone changed from 2.8 Release to 2.9 Release

Changed 4 years ago by gregers

Support radius for Canvas.drawPoint

Changed 4 years ago by gregers

  • state set to Review
  • version changed from 2.8 RC4 to SVN

I noticed the same problem, and came to the same solution. Created a patch, since I know the committers prefer that ;)

Since there was no fallback for style.pointRadius in SVG, I did not include this part: style.pointRadius?style.pointRadius:6

Changed 3 years ago by bartvde

  • keywords canvas radius removed
  • status changed from new to closed
  • state changed from Review to Complete
  • resolution set to fixed

(In [10104]) support pointRadius for canvas renderer, p=gregers, r=me (closes #2126)

Note: See TracTickets for help on using tickets.