[Mapserver-users] Implementing QueryByAttribute
Jeff Berry
jeffb at erlandsen.com
Fri Dec 13 10:23:50 PST 2002
I'd like to add a simple query tool that allows the user to enter a parcel
owner name, hit a search button and, for now, simply have the map find the
parcel and zoom the map to it. Eventually I want it to populate the query
results table just as if the user had used the Identify tool, but one step
at a time. I've looked through the archives for examples on how to use
QueryByAttribute and I sort of understand the code snippets I've found, but
being a novice with with PHP and web development in general, I'm a bit
confused on how to actually implement the code to do a parcel search.
Below is the code I've included in the main PHP code of my phtml file.
There is a textline labeled OwnerName. I get a parser error on the
QueryByAttributes line. I don't know what I'm doing wrong.
Any suggestion as to what the problem is?
if ($HTTP_FORM_VARS[OwnerName])
{
$layer->$map->getLayerByName('parcels');
$layer->{status} = MS_ON;
$layer->{filteritem} = "OWNER";
$layer->setfilter("\"$OwnerName\"");
&rv = $layer->queryByAttributes($map, MS_SINGLE);
if ($rv == MS_SUCCESS)
{
for ($i=0; $1<$layer->{resultcache}->{numresults}; $i++)
{
$result = $layer->getResult($i);
$rvshape = $layer->getShape($shape, $result->{tileindex},
$result->{shapeindex});
$shpbnd = $rvshape->bounds;
&map->setextent( $shpbnd->{xmin}, $shpbnd->{ymin},
$shpbnd->{xmax}, $shpbnd->{ymax} );
}
}
}
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