[Mapserver-users] PHP/Mapscript -- Help doing queries
Ed Martin
edman007x at mac.com
Sun Mar 14 06:49:16 PST 2004
this is my first time doing queries with mapscript and i'm having some
problems, first i can't find any way that i can just put the shape
indexes of the results into an array along with the NAME value of the
dbf file, so since i can't do that i decided i would try to use a
template and then maybe i'll read the results from the template and put
into an array, but i can't get the template working, i get no errors at
all but it returns nothing, not even the static information in the
template, so i changed the template file to the php file i was working
on, and it worked but i can't use the php file as template, and the two
files have the same permissions and are in the same folder
so how can i get the templates working or preferably skip the template
and put the info i need into an array, please help
here is the template i'm trying to use
<tr>
<td>
<a href="index.phtml?shp=[shpidx]">[NAME]</a>
</td>
</tr>
here is the php that i'm using
dl("php_mapscript.so");
$map = ms_newMapObj("map/map.map");
//zoom/pan the
$extent_to_set = explode(" ",$_SESSION['extent_old']);
$map->setextent($extent_to_set[0],$extent_to_set[1],
$extent_to_set[2],$extent_to_set[3]);
//calculate the coords
$x_click =
($_POST['mapa_x']/$map->width*($extent_to_set[2]-
$extent_to_set[0]))+$extent_to_set[0];
$y_click =
($_POST['mapa_y']/$map->height*($extent_to_set[3]-
$extent_to_set[1]))+$extent_to_set[1];
$cities_layer = $map->getLayerByName('Cities');
$point_obj = ms_newPointObj();
$point_obj->setXY($x_click,$y_click);
$query_tf = @$cities_layer->queryByPoint($point_obj,MS_MULTIPLE,-1);
if ($query_tf == MS_SUCCESS){
echo 'Query worked<br />';
echo $cities_layer->getNumResults().' places found';
$query = $map->processquerytemplate('',FALSE);
echo "<table>$query</table>";
} else {
echo 'Query Failed';
}
and here is a bit of the map file
LAYER
NAME "Cities"
TYPE POINT
STATUS default
DATA
"/usr/local/apache/htdocs/adsbytown/site/mapserver/map/data/ci10de03"
LABELMAXSCALE 1025400
LABELITEM "NAME"
MAXSCALE 4101800
LABELCACHE on
TOLERANCE 25
TOLERANCEUNITS miles
METADATA
"title" "Title"
"author" "Me!"
END
CLASS
TEMPLATE /usr/local/apache/htdocs/adsbytown/site/mapserver/query.tpl
#php file i used was
/usr/local/apache/htdocs/adsbytown/site/mapserver/index.phtml
More information about the MapServer-users
mailing list