[mapserver-users] Pre-defined Zoom In/Zoom Out buttons...
Joe Bussell
joe at otsys.com
Fri Sep 27 14:55:53 PDT 2002
The beauty of Javascript is that it is by definition open for copiing.
I encourage you to steal whatever you map find useful, though I will not
defend the style.
My idea was to maintain a center position and a level. The extent is
then calculated as a function of the two. In my world I have a 6 degree
spread in lat and lon. My function for the extent is:
deltaDegree = (max delta) / 2^level
so at level0 I get 6/2^0 = 6 degrees
at level1 I get 6/2^1 = 3 degrees
at level2 I get 6/2^2 = 1.5
...
at level10 I get 6/2^10 = 0.005859375
I then add/subtract to get my top, bottom, left, and right values.
In truth I am serving raster images with defined scales, so I need
to match up the result with the raster image. I have created my rasters
with a given size. I need to scale my result to match in case I am
presenting an odd shaped image.
var span = level0Span/Math.pow(2,zoomLevel) * mapNameExtentHash[ map ].imageSize / rasterImageSize;
top = lat + span;
bottom = lat - span;
left = lon - span;
right = lon + span;
I have no feeling as to whether this is a good methodology, but it works
for me. I am presently carriing around values for the present extent,
and am calculating the center point as needed. This seems like the
wrong choice, so I am migrating to a center-point & level based state.
Cordially,
Joe Bussell
On Time Systems
On Fri, Sep 27, 2002 at 01:46:46PM -0500, Mike Smith wrote:
> I could easily implement a new variable like your "zoomLevel"...I was
> already thinking that I needed to do that. And I've got a series of
> little buttons next to my map that make up a zoom bar like yours, and
> each button (when clicked) makes a call to a javascript function that
> I've written called "zoomTo". So I've got the framework there, I just
> can't figure out how to set my imgext based on this zoomLevel factor
> (relative to my map's maximum extent, not the current zoom level). I'd
> like to do just what you're doing on your page and have each zoom button
> present the same imgext and zoom level each time...right now I'm just
> incrementing the Mapserver variable "zoom" and "zoomsize" and the
> buttons build on the last zoom, instead of always zooming to a set
> factor relative to max extent. I don't want to ask you for your
> proprietary source code, but can you shed any light on what kind of
> algorithm I might use to determine the new imgext as a function of max
> extent and zoomLevel?
>
> Also, as Puneet pointed out, I will not be overriding the mouse click
> coordinates with this zoom level, so that the zooming will happen
> relative to whatever image center the user has already clicked on, and
> if they haven't clicked anywhere then I'll zoom straight into the
> centerpoint of my main map.
>
> Thanks!
>
>
>
> Joe Bussell wrote:
>
> >www.TrafficDodger.com has just such a zoom bar. I view it like fliing
> >at different altitudes. The higher you go, the more area you see and
> >you see less detail. I use a zoomLevel variable in my javascript. Each
> >button triggers a call to zoomToLevel with its own arguments. Regular
> >zoomIn and zoomOut increment and decrement this value. I then determine
> >the extent based on some function of the zoomLevel and my full scale
> >range.
> >
> >Cordially,
> >
> >Joe Bussell
> >On Time Systems
> >www.TrafficDodger.com
> >
> >
> >
> >On Fri, Sep 27, 2002 at 09:45:06AM -0500, 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
> >>
> >>
> >
>
--
Cordially,
Joe Bussell
On Time Systems
www.TrafficDodger.com
More information about the MapServer-users
mailing list