[mapserver-users] Pre-defined Zoom In/Zoom Out buttons...

Puneet Kishor pkishor at GeoAnalytics.com
Fri Sep 27 12:14:59 EDT 2002


On Friday, September 27, 2002, at 09:45  AM, Mike Smith wrote:

> Sorry to bother everyone with this, I know this has been addressed 
> before in the archives, but I can't seem to find it when I search > them.
>
> I'm trying to enable a Zoom In/Zoom Out bar along side my map (kinda 
> like Mapquest or Yahoo maps) where there are buttons that either zoom 
> the user in or out to pre-determined levels.  I've got Javascript code 
> that zooms in and out ok, but the logic is what's throwing me off.  I 
> want the bottom button to always be the same view, not zoom them out 
> 15 times from whatever their present view is.... it should zoom them 
> out 15 times from full extent.  I want "full extent" to be the base 
> and each button whether it's a zoom in or out button needs to always 
> zoom them to the same factor relative to full extent, not their 
> current view...make sense?  I know I've seen a Mapserver page before 
> that had this little zoom bar that I'm describing, but I can't 
> remember where I saw it. Anybody have a web page that does this?  Or 
> example code that handles the logic of pre-defined absolute zoom 
> levels (as opposed to the relative ones that the CGI variable "zoom" 
> sets)?
>
> Thanks
>

you need to set the new zoomextent relative to the maxextent (as you 
correctly surmised above).

Here are the steps you would take via mapscripting (dunno about cgi) --

1. You want to send a point back to the server relative to which you 
want to zoom (in or out). For example, if the user has already been 
clicking on the map and managed to navigate her way to some specific 
section of the map, and now clicks on your zoom bar, you want to zoom 
relative to the current extent (the user will be very annoyed if you 
zoom relative to the actual center of the image). On the other hand, if 
the user has not yet clicked on the map, you want to zoom relative to 
the actual center of the image. You can determine what the case is by 
embedding user clicks in hidden form fields... if those form fields are 
empty then the user hasn't clicked yet, etc.

2. Create your zoombar using a graphic or whatever, and use Javascript 
to send back a zoomfactor... zooming in will increase the zoomfactor, 
and vice versa.

3. Use the point you have sent back and the zoomfactor you have sent 
back to zoom from the max extent. You can easily grab the maxextent 
using mapscript, or you can even grab it once and then either insert it 
in session vars or shuttle it back and forth using form vals.

pk/




More information about the mapserver-users mailing list