-
-
Notifications
You must be signed in to change notification settings - Fork 6k
Zoomlevelschange event #1376
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
Zoomlevelschange event #1376
Conversation
This is triggered when you remove a layer from a map with greater zoom level coverage than the remainding layers or when you add a tilelayer with greater zoomlevel coverage than the previous set of layers had.
| @@ -271,6 +271,10 @@ L.Map = L.Class.extend({ | |||
| return Math.min(z1, z2); | |||
| }, | |||
|
|
|||
| getZoomLevels: function () { | |||
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.
Perhaps this method should be private (starting with _), I don't see any applications externally.
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.
I have a copy of that method in the zoomslider plugin and when I saw that I needed it here too I thought "why not just expose it?". It's just a one liner though so doesn't matter much to me one way or another. :)
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.
The less unessential methods API exposes the better, so lets still make it private.
And maybe change the name, as it suggests more of an array result, to something like _getZoomSpan or similar.
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.
Yep, agree! I'll go for _getZoomSpan, unless you actually prefer just doing:
var zoomSpan = this.getMaxZoom() - this.getMinZoom();inside _updateZoomlevels even?
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.
The above didn't make sense. Forgot i called getZoomSpan twice. Added a commit that fixes this just now.
|
Stable version usually only gets critical bugfixes and regression fixes, so I'd leave that up to master. |
|
That sounds reasonable. :) |
|
Looks good! |
|
Make a docs pull too. |
This code makes removeLayer and addLayer emit a zoomlevelschange-event if the zoomlevels were changed as a result of adding / removing the layer. Tests are included.
Please consider merging this also to stable (for 0.5.2) since I plan on making use of this in the zoom slider plugin (tell me if I should make a separate PR for that.