Ticket #1868 (closed bug: fixed)
WFS.setOpacity() doen't work properly
| Reported by: | openlayers | Owned by: | crschmidt |
|---|---|---|---|
| Priority: | minor | Milestone: | 2.8 Release |
| Component: | Layer.WFS | Version: | 2.7 |
| Keywords: | Cc: | ||
| State: | Complete |
Description
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.
/**
* Resolve the conflict between the method setOpacity() between
* OpenLayers.Layer.Markers and OpenLayers.Layer.Vector
*/
setOpacity: function(value){
if (this.vectorMode) {
OpenLayers.Layer.Vector.prototype.setOpacity.apply(this, [value]);
}
else {
OpenLayers.Layer.Markers.prototype.setOpacity.apply(this, [value]);
}
},

