-
-
Notifications
You must be signed in to change notification settings - Fork 6k
can't add scale control to uninitialized map #1063
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
Conversation
|
Sounds useful, although I don't like having two different behaviors in one interface depending on some hardcoded event types. Need to think this through. |
|
At the moment I think I'll just add |
|
I turned this into a PR that shows how this can be done pretty cleanly. See what you think. |
| } else { | ||
| events = this[key] = this[key] || {}; | ||
| events[types] = events[types] || []; | ||
| events[types].push({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you change this to avoid calling splitWords every time?
|
See this commit message for the rationale for those changes. |
|
I see now. Still don't quite like the addEventListener overloading approach — it's quite confusing, as you normally wouldn't expect the listener to be immediately called when attached — this detail is hidden in implementation. E.g. if you call How about adding a special method for map instead of overloading It would be simpler both in API and implementation. |
|
That's a good point -- I'll implement what you suggested. |
|
Please revert the alias changes then. I'm a perfectionist, what can be written shorter and simpler should be done so. :) |
|
Done. |
can't add scale control to uninitialized map
|
Looks good! |
This throws an error:
http://jsfiddle.net/CtJu7/1/
Can we special-case
map.on('load', callback)to work like jQuery load, triggering the callback immediately if the map has already been loaded? ThenScale#onAddcould do:And this code could be refactored.
I'll send a PR if you agree.