phpmapscript - examples on queries
Tim Schaub
tim at COMMENSPACE.ORG
Mon Aug 22 08:47:55 PDT 2005
> I´m new to mapserver, and i´m trying to figure out something
> as simple as making a simple query, using a click on the map
> and showing some layers attributes, but I couldn´t find some
> simple example in phpmapscript on how to do this.
You should be able to start with something like:
// assuming you have a point ($mapX, $mapY)
$queryPoint = ms_newpointobj();
$queryPoint->setxy($mapX, $mapY);
// assuming you want to query $queryLayer and return a single result
if(@$queryLayer->queryByPoint($queryPoint, MS_SINGLE, -1) == MS_FAILURE) {
exit("The point you selected did not intersect any features.");
}
// get the shape that was intersected
$aQueryResult = $queryLayer->getResult(0);
$aShapeIndex = $aQueryResult->shapeindex;
$aTileIndex = $aQueryResult->tileindex;
if($queryLayer->open() == MS_FAILURE) {
exit("Can't open ".$queryLayer->name);
}
$aShape = $queryLayer->getShape($aTileIndex, $aShapeIndex);
$queryLayer->close();
// get some value from a field named $fieldName
$aValue = $aShape->values[$fieldName];
Tim Schaub
www.commenspace.org
More information about the MapServer-users
mailing list