[Mapserver-users] Disable panning

Eric Bridger eric at gomoos.org
Thu Jul 15 11:19:59 EDT 2004


You can check current scale [scale] vs. the maps maximum scale
(hardcoded) and just return false;

This is not fool proof since the user can reach maximum scale but not be
centered in the maps full extent. Then they may get stuck.

I found I had this function, but don't think it worked perfectly. 
It has a note saying it needs more work.
This assumes you have a hidden form var: fullext with the hard-coded
full extents of the map. imgext contains the current map extent.

function checkPan(dir)
{
    document.mapform.pandir.value = dir;
    var imgext = document.mapform.imgext.value;
    if(imgext.split){
        var exts = imgext.split(' ');
        var fexts = document.mapform.fullext.value.split(' ');
        if((exts[2] - exts[0]) >= (fexts[2] - fexts[0])){
            return false;
        }
    }



On Thu, 2004-07-15 at 10:08, Lai, Kit wrote:
>  
> 
> How do I disable panning on the first page of the map or on the full
> extent of the map to prevent the map fell completely out of sight or
> scope, I am using Javascript panning, 
> 
> my Javascript code is as follows:
> 
>  
> 
> 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.mode[0].checked = true; // force browse
> 
>  
> 
>     document.mapserv.zoomdir[0].checked = true; // force pan
> 
>  
> 
>  
> 
>    document.mapserv.imgxy.value = x + " " + y;
> 
>  
> 
>     document.mapserv.target = "_top";
> 
>  
> 
>     document.mapserv.submit();
> 
>  
> 
>  
> 
>  
> 
>  }
> 
>  
> 
>  
> 
>  
> 
>  
> 





More information about the mapserver-users mailing list