Ticket #1868 (closed bug: fixed)

Opened 4 years ago

Last modified 4 years ago

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]);
                }
            },

Attachments

wfs_patch.txt Download (0.9 KB) - added by openlayers 4 years ago.
patch
wfs.patch Download (1.3 KB) - added by crschmidt 4 years ago.
changes setOpacity method, and adds a unit test to make sure it doesn't fail
wfs.2.patch Download (1.7 KB) - added by crschmidt 4 years ago.

Change History

Changed 4 years ago by openlayers

patch

Changed 4 years ago by crschmidt

  • owner changed from tschaub to crschmidt
  • status changed from new to assigned
  • milestone set to 2.8 Release

patch isn't valid, but i'll make it so and test it. this is clearly a mistake on my multiple inheritance stuff.

Changed 4 years ago by crschmidt

changes setOpacity method, and adds a unit test to make sure it doesn't fail

Changed 4 years ago by crschmidt

  • state set to Review

Changed 4 years ago by elemoine

  • state changed from Review to Needs More Work

crschmidt, your wfs.patch uses OpenLayers.Layer.Vector.prototype.setOpacity in both cases, which doesn't seem right.

Changed 4 years ago by crschmidt

Changed 4 years ago by crschmidt

  • state changed from Needs More Work to Review

Good catch, Eric. Fixed.

Changed 4 years ago by elemoine

  • state changed from Review to Commit

I would use call instead of apply here to save the array construction. Anyway, please commit.

Changed 4 years ago by crschmidt

  • keywords WFS opacity removed
  • status changed from assigned to closed
  • state changed from Commit to Complete
  • resolution set to fixed

(In [8952]) Fix for "WFS.setOpacity() doen't work properly". (Closes #1868) r=elemoine

Note: See TracTickets for help on using tickets.