[mapserver-users] Drawing Maps

Vinko Vrsalovic B. v at w.cl
Thu Jul 26 14:35:45 EDT 2001


> All I want to do is zoom in, when I click a point in my map.
> I can get the X Y cgi variables from the click on the image, but I dont =
> understand what i use to zoom in to that point??
> Do I set the extents? Create a point object. Is there any examples for =
> perl?  =20

It depends on the version of mapscript you're using, if it's 3.4
you have to set the new extent on your own, there's a perl example that
works on 3.4 in http://maps.dnr.state.mn.us/cgi-bin/mapquakes.pl

If you're using 3.5 there's a method from the map object called zoompoint,
here's an example in php, should be easy to port to perl:

$zoom_p = ms_newPointObj(); // new Point
$zoom_p->setxy($img_x,$img_y); // the coords of the click

$zoom_e = ms_newRectObj(); //new Rect

// here you must put the actual extent of the map (for sucessive zooms,
you have to keep the extent in a hidden variable and set the map extent
previously to the values that return from the submission of the form)

$zoom_e->setextent($map->extent->minx,$map->extent->miny,
		   $map->extent->maxx,$map->extent->maxy); 

$map->zoompoint($zoom_f,$zoom_p,$map->width,$map->height,$zoom_e,$zoom_m);

$img = $map->draw();

$zoom_f is the zoom factor, for a constant factor you just put an integer
there (ie zoom in in a factor of 2, just put 2).

$map->width and $map->height are the size in pixels of the image.

$zoom_m is another RectObj that sets the maximum extent (the map won't
zoom or pan more than what's set in this variable). It's optional.

you can refer to the docs in 
http://www2.dmsolutions.ca/webtools/php_mapscript/php_mapscript_docs.html
and use the perl equivalent for the calls on the methods.

hth,
-- 
V. <v at w.cl>



More information about the mapserver-users mailing list