[Mapserver-users] Zoom to Selected Feature
woodbri at swoodbridge.com
woodbri at swoodbridge.com
Fri Mar 28 19:11:57 PST 2003
Patrick,
I do this in my router display application
see http://imaptools.com/demos1/?tab=2
The way I solved this problem is to open the shapefile for the layer
and get its extents in mapscript, then you that info to $map-
>setextent()
My PHP code looks like this:
$router = ms_newShapefileObj($shapefile, -1);
$ext = $router->bounds;
/* increase bounds by 5%, do the math */
$rminx = 1.025*$ext->minx - 0.025*$ext->maxx;
$rmaxx = 1.025*$ext->maxx - 0.025*$ext->minx;
$rminy = 1.025*$ext->miny - 0.025*$ext->maxy;
$rmaxy = 1.025*$ext->maxy - 0.025*$ext->miny;
$map->setExtent($rminx, $rminy, $rmaxx, $rmaxy);
$router->free();
-Steve
On 28 Mar 2003 at 21:23, Patrick Rouse wrote:
> I've scoured the archives and seen this question asked before, but I
> didn't seem to see any clear cut answers, so here it goes again. I
> have a layer of weather stations and I would like to allow the user to
> input an ID and have the map zoom to that point. It would be similar
> to Steve Lime's 'find' tool on the MDNR browser, but would not launch
> a popup with one or many hyper link query results, it would
> automatically zoom to the point. I am sure this can be done, so I
> guess my real question is having one can assist with some sample code.
>
> Thank you
>
> Patrick Rouse
> Senior GIS Analyst
> The Weather Channel
>
>
More information about the MapServer-users
mailing list