-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Added zomeTune feature and continuous zoom #1941
Conversation
- zoomTune option allows to remap a level of zoom to a different level of tiles, for instance to have more zoom levels than available levels ot tiles. - continous zoom allows to show the tile layer with a non integer zoom level
…order to get accurate dragbox zoom)
Sorry for being late, I just got back from vacation and will thoroughly review this pull. Seems like a very interesting approach, although it complicates the code a bit. |
Continuous zoom would be amazing! |
No problem, but it is now my turn to be in holidays :) I can work on any correction when I am back (in about 10 days). Vladimir Agafonkin notifications@github.com wrote:
|
I know I'm not a contributor to this project, but I looked over the change, and it looked good to me (I reviewed it as I would a change in my work codebase). I'm excited about this new functionality. |
I just set up a very quick demo to test this code. When I mousewheel-zoom and I'm not on integer tile levels, the tile requests fail and the map goes grey. |
This should work better now. The problem occurred because the code was assuming the option zoomTune (as described above) was given. |
The zooming doesn't feel fluid when scrolling on my mac.. it's almost as if the discrete zoom levels were still there, but smaller. I was expecting it to continuous like the new google maps. I didn't set a |
The fluid animation is not related to this patch, it depends on AnimationZoom module, after doing some tests with and without. Did you included this module? |
I've been playing with these changes, and I keep seeing times when it tries to request tiles with an x value of 123.99999997 or something like that (i.e. close to an integer value, but not quite integer). If I round the request, then I start seeing wrong tile requests at very low zoom levels (zoomed way out). |
Can you provide your html file so I can try to reproduce this bug? |
Sure. Put this in the Leaflet base dir. Then just zoom in and out with mouse wheel or shift-click the +/- buttons in the zoom control
Eventually within 10 interactions I'll see bad tile requests as I described above. I've been mostly playing in chrome. |
After doing some testing, I could not reproduce the problem with:
Note that I commented inclusion of debug/css/screen.css, but I do not think it is the cause. May be the compiler command? Can you provide your "java -jar closure-compiler/compiler.jar -js etc..." I will reuse the same.
|
Hrm. I'm not compiling. The file I referenced just includes the source files. |
I did many tries again by directly referencing the sources, but the problem is not appearing :( |
In the test html I pasted above, replace the map creation line with this one
Just loading that html file now repros the problem on chrome, ff, and IE10. |
I have just tried your last patch with Opera, Firefox, Chrome and IE, this one cannot be reproduced. Are you sure your repository is up to date? I remember a similar problem months ago that I had corrected. |
Looks like that could be the issue. I applied your patch on top of the 0.7.1 stable branch. |
I also applied everything on 0.7.1 and it works without any problems, so far. Nice work, calandoa. |
Sounds like the error was on my side. Sorry about that! |
I get some ugly white gaps between tiles in some zoom levels, e.g.: var map = L.map('map').setView([51.505, -0.09], 3.1); or var map = L.map('map').setView([51.505, -0.09], 4.3); It happens nearly all the time at the X.1 and X.3 decimals. Other decimal levels work perfectly. Any suggestion, calandoa ? EDIT: Have some cases where even smaller zoom levels are called. It happens also at levels, such as 3.21, etc. |
Problem reproduced. I will investigate to understand the cause. |
I am currently debugging your modification, too. As far as I can tell it has something to do with the createTile function, see Line 532 at TileLayer.js. You added a "tileVirtSize" to calculate the correct inbetween zoom scale of a tile. I debugged at a zoom level of 3.1. The "tileVirtSize" variable produces a value of "274.37400640929104" which seem to create this weird behaviour. Rounding the "tileVirtSize" variable to the nearest integer didn't help at all. I will further investigate if this is really the cause and report back. |
…nded, e.g. with x=20.2 w=100.4 the following tile will be at 121, so the width must be rounded to 101 instead of 100.
…ull in the case where a map database is uncomplete.
I found out the problem. It is due to the fact that the sum of rounded floats is not always equal to the rounded sum of the same floats. I added a patch to correct this. However, if this is now working better with PC browsers, I sometimes still get gaps on my android smartphone. Unfortunately, I do not know here how to get the javascript console output. BTW, I also added a feature which automatically zoom out when zooming or moving on a location where no tiles can be loaded. |
Nice fix. |
This looks a lot better now on desktop browsers. I am not seeing the gap issue on my android phone, yet. Will report if it is happening at all. While debugging your script, I noticed a new bug. It only happens on my both mobile devices (Samsung S4 / S3). This bug was not introduced with your newest patch. It happens with and without your current patch. |
Quick update: after some serious refactoring of Leaflet zoom animation logic in the master branch (in addition to the GridLayer refactoring), I'm now ready to implement the ability to set zoom to a fractional value. But differently — not by resizing the tiles, because this is slow and may introduce gaps, but by transforming the tile container in the same vain as it happens during zoom animation. But this pull is still really useful as a reference for borrowing ideas, so I'm keeping it open. |
Thanks for the update, mourner. Your approach sounds interesting. Keep us informed as soon as you want to bounce your first version at us. We are ready for debugging and testing. |
Just got CSS Transforms powered fractional zoom working (though still some quirks left to fix), the work is happening here #2382 |
Closing the pull but keeping an eye on it, will continue working on the |
I added an option for the tile layer object which allows to use a set of tile with a different zoom level.
For instance, we want a zoom range between 4 and 10, but we only have the tiles for 6 and 8. Setting the
zoomTune
option with the following command allows to redirect zoom 4, 5 and 6 to tiles with level 6, and other zooms to tiles with level 8:It appears that implementing continuous zoom (aka non integer zoom level) was very easy after this, so I added a few modifications to the different control for testing and for making the best use of this new feature.
Note that
maxNativeZoom
anddetectRetina
seem useless (or at least can be simplified) with this new feature. Also, the code is not really optimized when changing the zoom slightly, as all tiles are discarded and put back. Only changing their size and position would be faster, but this was really too complicated with the current architecture.Note also that I am a complete beginner in JavaScript / git / GitHub, so there might be problems with this patch. BTW it has not been tested with jake (not working on my host) but with a few different browsers (Opera / Firefox / Chrome with Linux / Windows / Android).