panAndZoomTo a defined zoom level
HI,
I need to be able to pan and zoom a bit like the panAndZoomBy function does but would like to be able to zoom to a chosen zoomLevel.
let's say my map goes from 4 to 7 as zoomLevels I need to able to let's say panAndZoomTo zoom 5, and then go further to say zoom 7.
is it possible to do this in modestmaps? I have been looking at the various zoom and pan functions but can't find one that would take the user to a defined zoom level.
any pointers on how to do this?
thanks in advance
I need to be able to pan and zoom a bit like the panAndZoomBy function does but would like to be able to zoom to a chosen zoomLevel.
let's say my map goes from 4 to 7 as zoomLevels I need to able to let's say panAndZoomTo zoom 5, and then go further to say zoom 7.
is it possible to do this in modestmaps? I have been looking at the various zoom and pan functions but can't find one that would take the user to a defined zoom level.
any pointers on how to do this?
thanks in advance
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.
Create a customer community for your own organization
Plans starting at $19/month
-
Inappropriate?anybody??
-
Inappropriate?Are you asking how to perform a sequence of pans and zooms?
e.g. animate pan-and-zoom to a location at zoom level 15, THEN zoom in to zoom level 12?
Otherwise, I think map.panAndZoomBy should do what you want, e.g. to zoom in by 3 zoom levels and move the given location to the center of the map you would do:
var location:Location = new Location(...);
var center:Point = new Point(map.getWidth()/2, map.getHeight()/2);
var currentZoom:Number = map.getZoom();
var targetZoom:Number = currentZoom + 3;
var sc:Number = Math.pow(2, targetZoom - currentZoom);
map.panAndZoomBy(sc, location, center):void
If you use TweenMap this should animate... I'm sorry about the confusion between scale and zoomLevel in this function. -
Inappropriate?hey thanks for the answer, I didn't get an email about it and I just found it now.
that helped although I am still confused.
let's say I want to panAndZoomBy from any given zoom to let's say zoom 12 so I could be at zoomLevel 9 or 10 or whatever else and I need to panAndZoomBy to zoom 12 at a given location.
how do I calculate sc?
thanks for your help.
Luigi
I’m confused
-
Inappropriate?The scale value is always as I have it above:
var sc:Number = Math.pow(2, targetZoom - currentZoom);
This works for zooming in and zooming out. (e.g. 2 to the power -1 is 0.5, so everything will be half the size if you zoom out by -1).
This method really should have used zoom levels and not scale values, but the calculation above is all you need.
Loading Profile...



EMPLOYEE