[Mapserver-users] Perl Mapscript - equivalent of zoompoint method..?

Eric Bridger eric at gomoos.org
Thu Jul 10 09:44:41 EDT 2003


Ali,
In the Wiki, mapquakes.pl example:
 http://mapserver.gis.umn.edu/cgi-bin/wiki.pl?PerlMapScriptExamples35ex2 there is a function called set_extent() which takes the users mouse click and zooms the map to that point.  Is that what you need?
If no zoom is set, $zoom_dir == 0,  then this functions as a pan tool, recentering the map.

Steve Lime wrote mapquakes.pl.  I also adapted some javascript of his into Perl to handle pan direction buttons.  This just adjusts the mouse click image coordinates which then must be passed to set_exent().

sub pan_to_map {
    my ($map, $direction) = @_;
    my $pansize = .50;
    my ($x, $y) = (0,0);
    my $width = $map->{width};
    my $height = $map->{height};

    if($direction eq 'n') {
      $x = ($width-1)/2.0;
      $y = 0 - ($height * $pansize)/2.0;
    } elsif($direction eq 'nw') {
      $x = 0 - ($width * $pansize)/2.0;
      $y = 0 - ($height * $pansize)/2.0;
    } elsif($direction eq 'ne') {
      $x = ($width-1) + ($width * $pansize)/2.0;
      $y = 0 - ($height * $pansize)/2.0;
    } elsif($direction eq 's') {
      $x = ($width-1)/2.0;
      $y = ($height-1) + ($height * $pansize)/2.0;
    } elsif($direction eq 'sw') {
      $x = 0 - ($width * $pansize)/2.0;
      $y = ($height-1) + ($height * $pansize)/2.0;
    } elsif($direction eq 'se') {
      $x = ($width-1) + ($width * $pansize)/2.0;
      $y = ($height-1) + ($height * $pansize)/2.0;
    } elsif($direction eq 'e') {
      $x = ($width-1) + ($width * $pansize)/2.0;
      $y = ($height-1)/2.0;
    } elsif($direction eq 'w') {
      $x = 0 - ($width * $pansize)/2.0;
      $y = ($height-1)/2.0;
    }
    $x = int($x);
    $y = int($y);

    return($x, $y);
}

Eric


At 12:37 PM 07/10/2003 +0100, AMC Story wrote:
>Hi there everyone,
>
>I'm using Perl Mapscript to develop the interface of my application, and have 
>very kindly been given some existing code to work from from another member of 
>the list.  The code that I am making reference to is written using PHP 
>Mapscript, so I'm having a little bit of trouble in that not all of the methods 
>available with PHP Mapscript are available with the Perl version.
>
>I'm dealing with my panning buttons at the moment, and the example I have 
>defines a point object which the new map will zoom to, and then uses the 
>zoompoint method of the map object.  This method isn't available in Perl, does 
>anyone have any suggestions as to how I might get around this?  Similarly, 
>their zoomin function makes use of the zoomrectangle method...
>
>Thanks for any light you can shed on this.
>Ali 
>_______________________________________________
>Mapserver-users mailing list
>Mapserver-users at lists.gis.umn.edu
>http://lists.gis.umn.edu/mailman/listinfo/mapserver-users




More information about the mapserver-users mailing list