REsize window question

Martin Weinelt mweinelt at PLANIGLOBE.COM
Mon Mar 21 03:10:53 PST 2005


On Friday 18 March 2005 09:35, Stéphane RIFF wrote:
> My mapserver application need to redraw the map when the window is resized.
> My problem is that i don't know how to keep the same extent
> in two map with different size !!! 

Using mapserver CGI you just send MAPEXTENT and MAPSIZE
to the CGI (together with layers, etc.) and that's it.

> in fact i don't want the map 
> to change its scale when i resize the window.

Keeping mapextent at different mapsize yields another scale, no?

> How can i calculate the newExtent to do that ???
> Is it possible ???

You  do not calculate it, you just reuse the image extent from the previous
map (which can be sent by the CGI together with the image).

> How do you handle that kind of function ? example ?

I do it on the client side with js:

 function setMapSize() {
  // mimg is a div in the doc with the map as background image
  mimg.style.backgroundImage='url(images/waiting.gif)';
  // a 'wait indicator' is shown until the new image arrives
  // w is the browser window
  var mh = (w.innerHeight) ? w.innerHeight : d.body.clientHeight;
  var mw = (w.innerWidth) ? w.innerWidth : d.body.clientWidth; 
  mh-=60; mw-=230;             // correct for other elements which also need a bit of screen real estate
  mimg.style.width=mw; mimg.style.height=mh;  // set the div to the new size
  myMap.mode='browse';            //  myMap is an object which holds some map parameters
  myMap.mapsize=[mw,mh];       // ... mapsize for instance
  myMap.mapext.set(myMap.imgext.get());        // or map extent - here copied from the last image recieved 
  var s=myMap.getReqStr('mapsize','mapext');  // this  glues a GET-string for the new map request 
  getMap(s);                                 // invokes the new map
}

this is just an example, the same purpose can be served in a more traditional way.

Cheers, Martin



More information about the MapServer-users mailing list