Ticket #2022 (closed bug: fixed)

Opened 4 years ago

Last modified 4 years ago

Vector layer disappears when SelectFeature control is deactivated

Reported by: elemoine Owned by: elemoine
Priority: blocker Milestone: 2.8 Release
Component: Control.SelectFeature Version: 2.7
Keywords: Cc:
State: Complete

Description

[9116] introduced a regression, making the layer disappear when the SelectFeature control gets deactivated.

The bug can be reproduced with  http://www.openlayers.org/dev/examples/select-feature.html

Use case 1:

  • select "draw polygon"
  • draw a polygon
  • select "select feature"
  • select "draw polygon" -> the polygon disappears

Use case 1:

  • select "select feature"
  • select "draw polygon"
  • draw a polygon -> the polygon isn't persisted

Attachments

2022.patch Download (3.3 KB) - added by ahocevar 4 years ago.

Change History

Changed 4 years ago by ahocevar

Changed 4 years ago by ahocevar

  • state set to Review

The above patch fixes the issue. renderer.getRenderLayer() was unable to determine the layer, because it was no longer in the map's layers array. Using layer id now instead, which is always reliable.

On a side note: the only thing that I felt bad about when creating the final patch for #1666 was the fact that renderer.getRenderLayer() failed when the layer is not added to a map. Well, looks like I should have trusted my bad feeling then...

Anyway, Eric, can you please review and confirm if the patch fixes your issue? All tests still pass.

Thanks!

Changed 4 years ago by tschaub

  • owner changed from tschaub to elemoine

Changed 4 years ago by elemoine

  • state changed from Review to Commit

I can confirm that Andreas' patch fixes the issue. And the patch looks good. Big thanks for fixing this so quickly Andreas! Please commit.

Changed 4 years ago by ahocevar

  • status changed from new to closed
  • state changed from Commit to Complete
  • resolution set to fixed

(In [9160]) changed the renderer's getRenderLayer method to getRenderLayerId, which always works even if the layer is not added to a map. Also removed an unneeded map.events.unregister from Control.SelectFeature. r=elemoine (closes #2022)

Note: See TracTickets for help on using tickets.