[mapserver-users] Itemquery in Mapscript(PHP)

Laurent FOULONNEAU adsllaurentf at canl.nc
Thu Aug 30 07:48:27 EDT 2001


Could certainly be improved.....
First you have a blank image, when you use the search form, your object is
'automagically' ;) zoomed and painted in red

The others object are not showed.

Laurent

//--------------------------------------begin draw_query.php
<HTML>
<?php

dl("php_mapscript.dll");   // PHP4

// variables globales
$map_obj= ms_newMapObj("yourmapfile.map");
$red = $map_obj->addColor(255, 0, 0);

// fonctions
function DrawQueryMap()
{
GLOBAL $map_obj,$mode,$item, $qlayer, $value,$red;
if($qlayer && $mode == "itemquery" && $value && $item)
{
$layer = $map_obj->getlayerbyname($qlayer);
for ($c=0; $c < $layer->numclasses; $c++)
 {
 $class=$layer->getclass($c);
 if ($class->name == $item)
  {
   $class->setExpression($value);
   $class->set("color", $red);
  }
 }
}





$img = $map_obj->draw();
$url = $img->saveWebImage($img, 0, 0, -1);
echo"<INPUT  TYPE=image SRC=$url  BORDER=0 WIDTH=$map_obj->width
HEIGHT=$map_obj->height NAME=mainmap>";
}



?>

<HEAD>
 <?php DrawQueryMap() ?>

</HEAD>
<FORM>
        <input type="hidden" name="mode" value="itemquery">
        <input type="hidden" name="item"
value="your_class_name_in_the_map_file">
        <input type="hidden" name="qlayer"
value="your_layer_in_the_map_file">
        <input type="TEXT" size="30" name="value" value="">
        <input type="submit" value="Search">
</FORM>

</HTML>
//------------------------------------- end of draw_query.php

//-----------------------------yourmapfile.map : add a  layer with a class
name and a classitem with the same name
LAYER
  NAME your_layer_in_the_map_file
  TYPE POLYGON
  STATUS ON
  DATA your_shape_file
  CLASSITEM "your_class_name_in_the_map_file"
  CLASS
   NAME "your_class_name_in_the_map_file"
     END
END # layer
//----------------end of layer definition



----- Original Message -----
From: "Arthur, John" <John.Arthur at voicestream.com>
To: <mapserver-users at lists.gis.umn.edu>
Sent: Thursday, August 30, 2001 7:10 AM
Subject: [mapserver-users] Itemquery in Mapscript(PHP)


> Sorry if this is documented somewhere, but I couldn't find anything on how
> to perform an Itemquery in PHP mapscript(not cgi).
> I would like to type a search on a field (in a point or polygon layer) and
> return a map zoomed in on that search.
>
> John Arthur
> RF Technician
> Office:   (757) 490-7221
> Cellular: (757) 692-1515
> Email: john.arthur at voicestream.com
> _~-^-~_
> VoiceStream
> W I R E L E S S
>




More information about the mapserver-users mailing list