Skip to content

Conversation

jfirebaugh
Copy link
Member

Detecting when the base layer has changed (e.g. from clicking in a Layers control) is harder than it should be.

The Layers control does not define the order in which it adds and removes layers, so input that changes the base layer may result in a layeradd event followed by a layerremove event, or a layerremove event followed by a layeradd event. This means that any handlers that are bound to either or both events cannot assume that the map has exactly one base layer. It may have zero, one or two depending on the order of events.

I suggest that the Layers control trigger a baselayerchange event on the map after responding to input that changes the base layer. This event would be triggered after the other layer events, and it would include a layer property set to the resulting base layer.

@ghost ghost assigned mourner Oct 12, 2012
@jfirebaugh
Copy link
Member Author

Converted to pull request.

@mourner
Copy link
Member

mourner commented Oct 12, 2012

Nice idea with testing! Merging, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants