PHP/Mapscript Query
Julien-Samuel Lacroix
jlacroix at DMSOLUTIONS.CA
Wed Jun 15 08:34:15 PDT 2005
Hi,
You can use the QueryByPoint function to get the information on which
object you clicked.
// Note that the code is untested
$qx = /*longitude*/;
$qy = /*latitude*/;
$point = ms_newpointOBj();
$point->setXY($qx, $qy);
$layer = $map->getLayerByName("layer_name");
$data = $layer->queryByPoint($point, MS_SINGLE, -1);
$result = $layer->getResult(0);
$layer->open();
$items = $layer->getitems();
$shape =$layer->getShape($result->tileindex, $result->shapeindex);
$layer->close();
$data_val = $shape->values;
Then you can create a temporary layer that will draw only this object
(it's called a feature.).
//Untested
$layer2 = $map->getLayerByName("highlight_layer");
$layer2->set("data", $layer->data);
$layer2->set("classitem", "ID"); // Name of the field that contains your
// unique ID
$class = $layer2->getClass(0);
$class->setExpression($data_val['ID']);
Code like that will draw only the feature with the ID of the object you
clicked on.
Julien
On 06/14/2005 06:06 AM, Philippe Gondek wrote:
> Hi,
>
> I use PHP/Mapscript. I want to click on my map and see the object I
> clicked highlighted and see the metadata of the object. I don't see
> any good documentation about this functionnality...
>
> How can I do???
>
>
--
------------------------------------------------------------
Julien-Samuel Lacroix jlacroix at dmsolutions.ca
DM Solutions Group http://www.dmsolutions.ca/
------------------------------------------------------------
More information about the MapServer-users
mailing list