[Mapserver-users] RE: JBox Image swapping

Palanisamy, Giri palanisamyg at ornl.gov
Tue Nov 11 08:01:08 EST 2003


Hi,

I am using JBox in my mapserver application, and I like to do the image
swapping (reloading the map in the applet without refreshing the entire
page) when the user zooms in/out or pan.

Does any one provide a code example for this? I have found a very brief
documentation in the Mapserver's JBox how to do document, but couldn't
proceed further.

Thanks in advance

Giri

-----Original Message-----
From: Richard Greenwood [mailto:Rich at GreenwoodMap.com] 
Sent: Sunday, November 09, 2003 1:04 PM
To: Palanisamy, Giri
Cc: mapserver-users at lists.gis.umn.edu
Subject: Re: Image swapping

At 10:18 AM 11/9/2003, Giri Palanisamy wrote:
>I am trying to implement image swapping (reloading the map without
>refreshing the entire page), DO you have an example javascript code
that
>does this? Can you please send the code to me?,

Giri,

I am copying the mapserver list with this email as there may be members
of 
the list who can provide a good example.

I do not use image swapping, so I do not have an example. I am pretty
sure 
Steve Lime is using it in Landview:
    http://www.dnr.state.mn.us/maps/landview.html


>I referred your JBox how to do, it says I need to add
>var url;
>         url = "http://www.somedomain.com/cgi-bin/mapserv"+
>                 "?mode=map" +
>                 "&map=" + mapfile +
>                 "&mapext=" + extent.join("+") +
>                 "&mapsize=" + width + "+" + height +
>                 "&layers=" + layerlist;
>         document.jBox.setimage(url);
>
>Do I need to do this in a separate javascript function or add it to one
>of my existing function?

Add it to your existing function, but use that instead of 
"document.mapserv.submit();" In other words, you do NOT want to submit
the 
whole page, you want to call the setimage(url) function instead.

You may need to eval the function, something like:
    eval(" document.jBox.setimage(" + url + ")" );

Rich


>Here is my javascript:
>
><SCRIPT LANGUAGE="JavaScript">
>
>   function setbox_handler(name, minx, miny, maxx, maxy, redraw) {
>     document.mapserv.imgbox.value = minx + " " + miny + " " + maxx + "
"
>+ maxy;
>     document.mapserv.imgxy.value = minx + " " + miny;
>     if (redraw) {
>        document.mapserv.submit();
>     }
>   }
>   function seterror_handler(message) {
>     alert(message);
>   }
>   var pansize = 0.80;
>
>   function pan(direction) {
>     var x, y;
>
>     if(direction == 'n') {
>       x = ([mapwidth]-1)/2.0;
>       y = 0 - [mapheight]*pansize + [mapheight]/2.0;
>     } else if(direction == 'nw') {
>       x = 0 - [mapwidth]*pansize + [mapwidth]/2.0;
>       y = 0 - [mapheight]*pansize + [mapheight]/2.0;
>     } else if(direction == 'ne') {
>       x = ([mapwidth]-1) + [mapwidth]*pansize - [mapwidth]/2.0;
>       y = 0 - [mapheight]*pansize + [mapheight]/2.0;
>     } else if(direction == 's') {
>       x = ([mapwidth]-1)/2.0;
>       y = ([mapheight]-1) + [mapheight]*pansize - [mapheight]/2.0;
>     } else if(direction == 'sw') {
>       x = 0 - [mapwidth]*pansize + [mapwidth]/2.0;
>       y = ([mapheight]-1) + [mapheight]*pansize - [mapheight]/2.0;
>     } else if(direction == 'se') {
>       x = ([mapwidth]-1) + [mapwidth]*pansize - [mapwidth]/2.0;
>       y = ([mapheight]-1) + [mapheight]*pansize - [mapheight]/2.0;
>     } else if(direction == 'e') {
>       x = ([mapwidth]-1) + [mapwidth]*pansize - [mapwidth]/2.0;
>       y = ([mapheight]-1)/2.0;
>     } else if(direction == 'w') {
>       x = 0 - [mapwidth]*pansize + [mapwidth]/2.0;
>       y = ([mapheight]-1)/2.0;
>     }
>
>     document.mapserv.zoomdir[1].checked = true; // force pan
>     document.mapserv.imgxy.value = x + " " + y;
>     document.mapserv.submit();
>
>   }
>
>  </SCRIPT>
>
>
>Thanks for the help.
>
>Giri




Richard W. Greenwood, PLS
Greenwood Mapping, Inc.
Rich <at> GreenwoodMap <dot> com
(307) 733-0203
http://www.GreenwoodMap.com 





More information about the mapserver-users mailing list