[mapserver-users] Fixed pan buttons with PHP Mapscript

Antti.Roppola at brs.gov.au Antti.Roppola at brs.gov.au
Mon Nov 18 21:21:12 EST 2002


Hi Jeff,

Use $map->extent-> to find the current extent of your map (it's a rectObj).

>From there, it would be a simple matter to set up some buttons that
increment the view by half the current displayed width:

	$xmax = $map->extent->{xmax};
	$xmin = $map->extent->{xmin};
	$xinc = ($xmax - $xmin ) / 2;

	// Move across half a view in the X
	if ($pan=="right") { // or whatever your "pan right" button does
		$map->setextent( ($xmin + $xinc), $ymin, ($xmax + $xinc), $ymax);
	}
	if ($pan=="left") { // or whatever your "pan left" button does
		$map->setextent( ($xmin - $xinc), $ymin, ($xmax - $xinc), $ymax);
	}
	...

Same sort of thing again for your other directions.

Cheers,

Antti

-----Original Message-----
From: Jeff Berry [mailto:jeffb at erlandsen.com]
Sent: Tuesday, 19 November 2002 11:25 AM
To: MapServer
Subject: [mapserver-users] Fixed pan buttons with PHP Mapscript


I'd like to be able to add 4 buttons around the map representing the 4
cardinal directions, that when clicked will pan the map precisely half the
current extent of the map in the specified direction.  I'm using PHP
Mapscript.  I'm pretty new to PHP and definitely new to Mapscript, and this
is my first real attempt at customizing Mapserver with Mapscript.  So, I'm
sort of shooting in the dark here and am not sure how to approach this.

My main question is how can I get access to the coordinates for the current
map extent? I've looked through the class descriptons for MapScript and see
the MapObj has rectObj as a member.  So, I assume I can get to the current
map extent through the rectObj, but I'm uncertain on exactly how to do this,
as far as the actual code.

I imagine someone has already done this, so if there is anyone willing to
share their code for a fixed pan button with a rookie, it would be a big
help.

Thanks,

Jeff Berry
Erlandsen & Associates
P.O. Box 2029
Chelan, WA 98816
(509) 682-4189
jeffb at erlandsen.com





More information about the mapserver-users mailing list