Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

need a baselayerchange event #1064

Merged
merged 1 commit into from
Oct 12, 2012
Merged

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.

mourner added a commit that referenced this pull request Oct 12, 2012
@mourner mourner merged commit 2f6bd65 into Leaflet:master Oct 12, 2012
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