[OpenLayers-Users] BUG - WFS.setOpacity() cannot work reliably

Christopher Schmidt crschmidt at metacarta.com
Mon Dec 8 11:48:58 EST 2008


On Mon, Dec 08, 2008 at 05:35:29PM +0100, Estanislao Gonzalez wrote:
> Hi,
> 
> I couldn't fill a bug for it, and don't have currently the time to find 
> out why... sorry.

Did you get an error or something?

> But if someone is kind enough, please do fill it.
> 
> The bug is caused because of the multiple inheritance of Layer.WFS 
> (inheriting from Layer.Vector and Layer.Markers). I presume the 
> intention is to fall back in case the browser doesn't support vector 
> rendering.
> 
> The method setOpacity for Layer.Markers is different from that of Layer 
> (which is the parent class of Layer.Vector) and depends on the markers 
> attribute. If WFS is on vectors (myWFS.isVector == true), the 
> overwritten setOpacity method tries to access 'markers' which happen to 
> be empty. And the nasty bugs prevents the rest of the script from 
> running normally.
> 
> The solution might be to decide which of the two methods should be used 
> (yep, redundant methods... yikes, but inheriting from more than one 
> class tends to do that). So here is my proposal which seems to run 
> perfect, at least as far as I could test.

This is close: The only thing that I would say is that instead of
copying the functions, you simply call them using the prototypes. Look
at the destroy method for a good example. 

If you turn this into a patch, I'll gladly review it.

>             OpenLayers.Layer.WFS.prototype.setOpacity = function(opacity){
>                 if (this.isVector) {
>                     //Sets the opacity to the whole layer
>                     //from OpenLayers.Layer.Vector
>                     if (opacity != this.opacity) {
>                         this.opacity = opacity;
>                         for (var i = 0, len = 
> this.div.childNodes.length; i < len; ++i) {
>                             var element = this.div.childNodes[i].firstChild;
>                             OpenLayers.Util.modifyDOMElement(element, 
> null, null, null, null, null, null, opacity);
>                         }
>                     }
>                 }
>                 else {
>                     // Sets the opacity for all the markers.
>                     // from OpenLayers.Layer.Markers
>                     if (opacity != this.opacity) {
>                         this.opacity = opacity;
>                         for (var i = 0, len = this.markers.length; i < 
> len; i++) {
>                             this.markers[i].setOpacity(this.opacity);
>                         }
>                     }
>                 }
>             };
> 
> 
> As I'm not in the OpenLayers architecture I might have forgotten to do 
> something, or neglected to take something into consideration. So if 
> someone is kind enough to point the bug and solution to the right 
> people, we all will get a better 2.8 version ;-)
> 
> Regards,
> Estani
> 
> -- 
> Dipl.-Kfm. Estanislao Gonzalez, Fraunhofer-Institut für Software- und Systemtechnik ISST
> Location-based Services, Steinplatz 2, 10623 Berlin, Germany
> Telefon: +49 (0) 30 / 2 43 06-3 36
> mailto:estanislao.gonzalez at isst.fraunhofer.de
> www.isst.fraunhofer.de
> 
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users

-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list