[OpenLayers-Dev] return from renderer.drawFeature

Tim Schaub tschaub at opengeo.org
Thu Mar 31 18:39:29 EDT 2011


It looks like since r7930 we've been expecting renderers to return 
truthy values for features that actually get rendered.

http://trac.osgeo.org/openlayers/changeset/7930

The canvas renderer missed this change.

http://trac.osgeo.org/openlayers/browser/trunk/openlayers/lib/OpenLayers/Renderer/Canvas.js?rev=7930

So, unless I'm misreading, for the past 2.5 years we've been doing an 
unnecessary drawFeature call for every feature on every pan in the 
canvas renderer.

Volker Grabsch just put up a patch on a ticket so that we always return 
true in the canvas renderer's drawFeature method.  I committed a variant 
of that patch so the method acts more like the other renderers.

http://trac.osgeo.org/openlayers/changeset/11851

To be consistent with the NG renderer, the canvas renderer returns 
undefined if the feature has no geometry.  I see there are other tickets 
about dealing with features outside the extent of the viewport, and I 
assume these would result in a false return.

I'm unclear why there needs to be a difference in the return here.  The 
vector layer only checks if the return is falsey.  I'm not sure if there 
are any other custom renderers out there, but it would be safer in my 
opinion to check for === false in the vector layer.

Does anybody know if the difference in the returns is significant here?

Thanks,
Tim


-- 
Tim Schaub
OpenGeo - http://opengeo.org
Expert service straight from the developers.


More information about the Dev mailing list