How do I establish a set of preset zoom levels?
I'm experimenting with developing a mapping API based on Open Zoom and I would like to know how I might establish a set of preset zoom levels. I use a typical quadtree map tile service, with a set of integer zoom levels, each containing n 256 x 256 pixel tiles on each side of a square, where n = 2 ^ zoomLevel.
I would like to use Open Zoom to zoom to each one of these fixed levels, so that 1 screen pixel always represents 1 image pixel. In other words, I never want to be "between" zoom levels (except during the zoom tweening).
My problem is that I sometimes wind up on the "wrong" zoom level, where the previous map tile level is displayed at 2x magnification (or something like that) instead of showing the appropriate level at 1:1 magnification. And I don't know how to report which integer zoom level I am at, because I do not know how to translate between Open Zoom's scale and zoom values and this integer zoom level. Do you have any guidance on how to approach this problem?
I would like to use Open Zoom to zoom to each one of these fixed levels, so that 1 screen pixel always represents 1 image pixel. In other words, I never want to be "between" zoom levels (except during the zoom tweening).
My problem is that I sometimes wind up on the "wrong" zoom level, where the previous map tile level is displayed at 2x magnification (or something like that) instead of showing the appropriate level at 1:1 magnification. And I don't know how to report which integer zoom level I am at, because I do not know how to translate between Open Zoom's scale and zoom values and this integer zoom level. Do you have any guidance on how to approach this problem?
1
person has this question
I have this question, too!
Tell me when someone answers.
The more people who ask this question, the more it gets noticed.
The more people who ask this question, the more it gets noticed.
The company marked this question as answered.
-
Inappropriate?Trevor,
I might be wrong, but I think it's pretty easy to come up with a formula to map between your zoom levels and the scale property and it works like this.
OpenZoom's scale = 1 always corresponds to your highest integer zoom level. And since your integer zoom levels are based on powers of two, scale = 1/2 corresponds to the second highest zoom level and so forth. The generalized formula with your highest integer zoom level being maxLevel is:
scale = 1 / (2^(maxLevel - level))
or simplified:
scale = 2 ^ (-(maxLevel - level))
Considering I've come across a similar requirement — not landing in between zoom levels — I've come up with a solution in the form of the MapConstraint constraint which ensures the scale of the viewport is always a power of two.
Please have a look at the Flex mapping example:
http://github.com/openzoom/sdk/blob/a...
Let me know if this answers your question.
Cheers,
Daniel
The company says
this answers the question
-
Inappropriate?I tried using scale instead of zoom in the mouse wheel handler. The value of zoomLevel here is not important. It's just an integer that decreases as you zoom in:
if (event.delta < 0) {
zoomLevel += 1;
}
else {
zoomLevel -= 1;
}
viewport.scale = 1 / (Math.pow(2, zoomLevel));
It seems that this "skips" some zoom levels. My tile service has 18 levels, for an image width (and height) of 33,554,432 pixels at level 18. Starting with a single 256x256px tile at "maximum zoom out" world view, the mouse wheel zooms through only around 9 or 10 levels before it reaches the "maximum zoom in" at street level.
Also, when I set the viewport to scale 1.0, the image does not seem to correspond to the highest integer zoom level. It is somewhere between the highest and lowest (in fact, according to getTileURL in the descriptor class, it corresponds to map level 6). -
Inappropriate?Trevor,
I'm being open with you, due to time constraints because of my current status – http://gasi.ch/blog/joining-microsoft/ – I can't help you with the fundamental problem of level skipping.
However, regarding the scale discrepancy: I forgot to mention that the scale dimension is relative to the scene dimensions. That means you have to scale it by the ratio of your image dimensions to scene dimensions.
I hope this helps you at least a little bit to solve your problem.
–Daniel
The company says
this answers the question
Loading Profile...




EMPLOYEE