How to limit zoom and pan
Hello,
I'd like to limit my zoom-level (in both directions). Is that somehow possible?`
And I'd like to limit the pan-area as well if I've pan-buttons just as it works like if I use the mouse to drag the map. Any ideas on that?
—I'm using the AS2-version.#
Thanks a lot
I'd like to limit my zoom-level (in both directions). Is that somehow possible?`
And I'd like to limit the pan-area as well if I've pan-buttons just as it works like if I use the mouse to drag the map. Any ideas on that?
—I'm using the AS2-version.#
Thanks a lot
2
people have 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 best answers from the company
-
Actually, in lieu of a tutorial for the moment, this Microsoft explanation is not bad:
http://msdn2.microsoft.com/en-us/libr...
The company says
this answers the question
-
Eufemism, you can use the locationCoordinate methods of the map provider to determine the coordinates of the lat/lon bounding box you're looking for. Get the coordinate for the northwest location, zoom it to level 4, and assign that to __topLeftOutLimit. Get the coordinate for the southeast location, zoom it to level 16, and assign that to __bottomLeftInLimit.
I smell a tutorial coming on - this stuff can be quite confusing!
The company says
this answers the question
-
Thanks gwfran! If you look at the defineImageProperties() function definition in the abstract zoomify provider (http://modestmaps.mapstraction.com/tr...) it does do some of the limit gruntwork for you. It also has a big loop that establishes the coordinate boundaries of the "TileGroup" directories that Zoomifyer sets up.
The company says
this answers the question
-
The two limits are used in your map provider constructor.
The first defines how far up, left, and out you can zoom or pan (in terms of coordinates), and the latter defines the opposite. You can see an example here in the Blue Marble provider - this is the AS3 version, the AS2 version is similar:
http://modestmaps.mapstraction.com/tr...
In this case, you can zoom out to zero (whole world), in to nine, pan up to zero (north of the arctic circle), down to one at zoom level zero (antarctic), and left and right to infinity, because this is a cylindrical projection. You'll find that in all the mercator providers that ship with Modest Maps, these limits are identical because the world is divided in the same way:
http://s3.amazonaws.com/com.modestmap...
http://mt0.google.com/mt?n=404&v=w2.6...
http://tile.openstreetmap.org/0/0/0.png
I’m hopeful
The company says
this answers the question
Create a customer community for your own organization
Plans starting at $19/month
-
Inappropriate?Yes - each map provider class has two properties, __topLeftOutLimit and __bottomRightInLimit. These are instances of Coordinate, and define the furthest up, left, and out and the furthest down, right, and in the map can be panned or zoomed:
http://modestmaps.mapstraction.com/tr... -
Inappropriate?Could anyone tell me more specific how to use the __topLeftOutLimit and __bottomRightInLimit?
eg. where and how do you set them?
I’m confused
-
Inappropriate?The two limits are used in your map provider constructor.
The first defines how far up, left, and out you can zoom or pan (in terms of coordinates), and the latter defines the opposite. You can see an example here in the Blue Marble provider - this is the AS3 version, the AS2 version is similar:
http://modestmaps.mapstraction.com/tr...
In this case, you can zoom out to zero (whole world), in to nine, pan up to zero (north of the arctic circle), down to one at zoom level zero (antarctic), and left and right to infinity, because this is a cylindrical projection. You'll find that in all the mercator providers that ship with Modest Maps, these limits are identical because the world is divided in the same way:
http://s3.amazonaws.com/com.modestmap...
http://mt0.google.com/mt?n=404&v=w2.6...
http://tile.openstreetmap.org/0/0/0.png
I’m hopeful
The company says
this answers the question
-
Inappropriate?The way I approached zoom and panning limits was as migurski described. This uses the width and height (in pixels) of the Zoomify-ed map (in this case) to determine the max/min pannable regions (*_COORD variables). The minimum zoom for my map is 2 and the maximum is 7.
public static const WIDTH:int = 30000;
public static const HEIGHT:int = 15000;
public static const MIN_ZOOM:int = 2;
public static const MAX_ZOOM:int = 7;
public static const MIN_X_COORD:int = 0; //left margin
public static const MAX_X_COORD:Number = WIDTH / 256; //right margin
public static const MIN_Y_COORD:int = 0; //top margin
public static const MAX_Y_COORD:Number = HEIGHT / 256; //bottom margin
public function AbstractZoomifyMapProvider(URL:String)
{
super();
defineImageProperties(URL, WIDTH, HEIGHT);
var t:Transformation = new Transformation(4774.576019431266, 9.045704455491817, 14992.076797769103,
-0.6452136604760299, -4774.920472624757, 7501.453232547894);
__projection = new LinearProjection(15, t); // log(WIDTH) / log(2) rounded up
__topLeftOutLimit = new Coordinate(MIN_Y_COORD, MIN_X_COORD, MIN_ZOOM);
__bottomRightInLimit = (new Coordinate(MAX_Y_COORD, MAX_X_COORD, MAX_ZOOM)).zoomTo(MAX_ZOOM);
}
I’m happy
-
Inappropriate?Thanks gwfran! If you look at the defineImageProperties() function definition in the abstract zoomify provider (http://modestmaps.mapstraction.com/tr...) it does do some of the limit gruntwork for you. It also has a big loop that establishes the coordinate boundaries of the "TileGroup" directories that Zoomifyer sets up.
The company says
this answers the question
-
Inappropriate?Thanks for the quick replies guys!
But I'm still having problems, I just feel I don't understand anything about all these coordinates and values and no matter what I try I get really strange results, what I'm trying to do is to limit google/microsoft/yahoo maps to zoom level between 4 and 15/16, and limit the panning to an area around Norway/Sweden/Finland (zoom level 4 because it makes the entire height of the countries visible)
Is there any way I can use the long/lat coordinates of the top-left corner of the map and the coordinates of the bottom-right corner (after I've panned and zoomed to the area I want) to limit the pannable/zoomable area?
I’m confused
-
Inappropriate?So, assuming you modify the google/microsoft/yahoo providers and the width of your map is 30k x 15k won't this work? The zoom levels of 4 and 15/16 - are those the 2x zooms or fractional zooms? If fractional, then 2 and 7 are probably the corresponding 2x zooms.
public static const WIDTH:int = 30000;
public static const HEIGHT:int = 15000;
public static const MIN_ZOOM:int = 2;
public static const MAX_ZOOM:int = 7;
public static const MIN_X_COORD:int = (leftmost pixel to stop panning/256); //left margin
public static const MAX_X_COORD:Number = (rightmost pixel to stop panning/256); //right margin
public static const MIN_Y_COORD:int = (topmost pixel to stop panning/256); //top margin
public static const MAX_Y_COORD:Number = (bottommost pixel to stop panning/256); //bottom margin -
Inappropriate?Might work, but how do I know the width/height of a google map? And to make it AS2 compatible, can I just remove the "const" and ":int"? This project requires AS2, which is pretty bad concerning Modest Maps since the AS2 version seems a few generations behind the AS3 version =/
-
Inappropriate?Eufemism, you can use the locationCoordinate methods of the map provider to determine the coordinates of the lat/lon bounding box you're looking for. Get the coordinate for the northwest location, zoom it to level 4, and assign that to __topLeftOutLimit. Get the coordinate for the southeast location, zoom it to level 16, and assign that to __bottomLeftInLimit.
I smell a tutorial coming on - this stuff can be quite confusing!
The company says
this answers the question
-
Inappropriate?migurski: I tried but I don't get any results, I'm probably doing this in the wrong way/place but I'm trying to keep most of my stuff in a class called MapManager, where I added:
mapHolder.map.__mapProvider.__topLeftOutLimit = mapHolder.map.__mapProvider.locationCoordinate(new Location(72.1279, -19.4238));
mapHolder.map.__mapProvider.__bottomRightInLimit = mapHolder.map.__mapProvider.locationCoordinate(new Location(52.6964, 46.2305));
But apparently this doesn't work, so do I have to put it all in the MapProvider for the map I'll be using?
And a tutorial would be very much appreciated
gwfran: I tried your version and got the width/height with some trial and error and I got it to work, but as soon as I start zooming everything get's messed up and I ended up zoomed in on the ocean near Alaska, and my values only worked with zoom levels defined as 4 and 7, when I changed the 7 everything got messed up again.
This is very much a new territory for me and I'm greatful of all your help!
I’m unsure
-
Inappropriate?Don't forget to zoom!
__topLeftOutLimit = mapHolder.map.__mapProvider.locationCoordinate(new Location(72.1279, -19.4238)).zoomTo(4);
Trace out the coordinate before & after zoomTo() to see the difference. -
Inappropriate?When setting your coordinates in my "up front" method (that is, where you have the dimensions and all that jazz when you begin), you would need to do them at the highest zoom level. So trial and error would need to be done at the highest zoom level - not a very fun prospect. :-)
Migurski's definitely got the method for you to grab the limits using the code.
I’m confident
-
Inappropriate?Actually, in lieu of a tutorial for the moment, this Microsoft explanation is not bad:
http://msdn2.microsoft.com/en-us/libr...
The company says
this answers the question
-
Inappropriate?Is there a way to change de minimum zoom level at runtime ? I want my map to fit the screen of the user. If he has a 800 x 600 px screen, he won't be able to zoom out level 2 but if he got a 1024 x 768 px screen, I wont to block it at zoom 3.
Loading Profile...



EMPLOYEE



