Opened 6 years ago

Last modified 6 years ago

#448 new defect

Array access sometimes fails in VectorLegend#onFeaturesAdded

Reported by: gernot Owned by: tschaub
Priority: minor Milestone: 1.2
Component: GeoExt.VectorLegend Version: 1.0
Keywords: Cc:
State: None


I am using the GeoExt VectorLegend in combination with a lazily loaded Vector layer. In my case, OpenLayers sometimes sends a 'featuresadded' event with an empty features array. The onFeaturesAdded method does not handle this, which results in the following java script error 'this.layer.features[0] is undefined' in VectorLegend.js:279

Please find attached a patch that hot-fixes the problem. It would be great if you could fix the issue in the next version.

Attachments (1)

VectorLegend.js.patch (542 bytes) - added by gernot 6 years ago.

Download all attachments as: .zip

Change History (5)

Changed 6 years ago by gernot

comment:1 Changed 6 years ago by gernot

  • Type changed from enhancement to defect

comment:2 Changed 6 years ago by bartvde

if this is the case, I believe it would be better to solve the issue in OpenLayers in such a way that featuresadded is not triggered if there are no features (empty array). Do you have a simple HTML test page or an example to reproduce this issue? Which OpenLayers version are you using?

comment:3 Changed 6 years ago by ahocevar

  • Milestone changed from 1.1 to 1.2

Batch move of tickets to finish the 1.1 milestone.

comment:4 Changed 6 years ago by gernot

Sorry, i did not see your comment until now, the email was kind of lost...

I am using OpenLayer 2.11 and (now) GeoExt 1.1

The problem can be reproduced here:

GeoExt on this site is already patched, but I am currently using the non compressd libs, so you should be able to place a breakpoint in VectorLegend at line 282.

Note: See TracTickets for help on using tickets.