Zoom feature The usual (and simple) technique used in the world of GISs is to draw a zoom box on the map using the mouse. How is this implemented in Géoclip?
Let us first look at a diagram:  lc and hc are the width and height of the map frame, lz and hz are the width and height of the zoom area. The zoom factor is determined using the minimum value between hc/hz and lc/lz. This enlargement factor will be applied to the entire map.
But once the map has been scaled, there is no reason why the zoom centre should be the same as the centre of the map window. The map must therefore be moved (translated) so that the centre of the zoom box is at the centre of the map window. The problem is there are two different coordinate systems: the screen's, in which the map window and its centre always have the same coordinates, and the map's, which is subjected to scalings and translations.
We must therefore make two points coincide: the centre of the map window, whose screen coordinates are (CX,CY), and the zoom centre, whose coordinates in the map system are (zcx,zcy). The correction that must be made is determined using the distance between the two points in one coordinate system or the other, the main thing being that it be measured in the same system for both points. For example, let work with the screen system. We must therefore calculate the coordinates of the zoom centre in this system, i.e. change (zcx,zcy) to (ZCX,ZCY) and perform the translation (CX-ZCX,CY-ZCY). For more informatoin on calculating new coordinates, see Converting coordinates. But since Flash includes features for changing coordinate systems, we might as well use them. We must use the LocalToGlobal() function, which allows us to switch from the coordinate system of a particular object (here, the object "map" that contains the map) to the screen system: centre_zoom = [ { x : zcx , y : zcy } ]; map.localToGlobal(centre_zoom); ZCX=centre_zoom.x; ZCY=centre_zoom.y; the corrective translation (CX-ZCX,CY-ZCY) must then be performed in the coordinate system of the screen.
|