[Mapserver-users] Re: Image swapping
Richard Greenwood
Rich at GreenwoodMap.com
Sun Nov 9 10:03:44 PST 2003
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