[Mapserver-users] Pan
David Fawcett
David.Fawcett at state.mn.us
Tue Dec 9 09:47:02 PST 2003
Brent,
I have been just digging into the javascript in the workshop demo.
Below is the pan function from the itasca_adds_pan.html. In the last
few lines, you will see that there is a statement that forces the
zoom/pan option to pan.
I would assume that you could add a similar statement to force your
map/query mode to 'browse'.
How about something like:
document.mapserv.mode[0].checked = true; // force browse
David.
YMMV, I haven't tested this, just conjecture.......
<script language="javascript">
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>
David J. Fawcett
MN Office of Environmental Assistance
>>> Brent Lund <Brent.Lund at state.mn.us> 12/9/2003 11:05:13 AM >>>
I am attempting to add pan controls similar to Steve's example at
http://maps.dnr.state.mn.us/mapserver_demos/workshop/
<http://maps.dnr.state.mn.us/mapserver_demos/workshop/> (select the
"add
pan controls"). Steve's example works swell except when the user
selects a
query option and then decides to use a pan control. Rather than
panning
the user ends up with a query result.
I'm guessing there has to be a way to set the mode in the Pan
javascript
function. I haven't been able to figure out the syntax however -
anyone
know what that would be?
Thanks
Brent
More information about the MapServer-users
mailing list