[Mapserver-users] query dynamic layers...
Daniel Morissette
morissette at dmsolutions.ca
Tue Jul 22 06:43:53 PDT 2003
In the GMap application, the query call is done *before* the call to
GMapDrawMap() (search for QueryByPoint in the source files). So if you
create your layer inside GMapDrawMap() then the layer doesn't exist yet
when QueryByPoint() is called.
If you move the creation of your gro_layer somewhere before the call to
QueryByPoint then the it should be queried with all the other layers.
Daniel
Rainer Spittel wrote:
>
> Hi,
>
> I have a funny problem and I don't know what 'I' am doing wrong. I
> have a map file, called "test.map", containing two layers. The user
> shall append a new layer to the mapserver on the fly (e.g.
> "grp_points"). I am using MapServer 3.6.6 and PHP/MapScript and do the
> following stuff:
>
> <?php
> [...]
>
> function GMapDrawMap()
> {
> [...]
> $colorId = $gpoMap->addColor(22,222,222);
>
> $objLayer = ms_newLayerObj($gpoMap);
>
> $objLayer->set("name", "gro_layer");
> $objLayer->set("type", MS_LAYER_POINT);
> $objLayer->set("status", MS_ON);
> $objLayer->set("data", "./gro_points");
>
> $objLayer->set("template", "ttt.html");
>
> $objLayer->setMetaData("DESCRIPTION","Custom features (Points)");
> $objLayer->setMetaData("RESULT_FIELDS","PROG_IN ATTRIBUTE CLASS");
>
> $objClass = ms_newClassObj($objLayer);
> $objClass->set("name","test");
> $objClass->set("color", $colorId);
> $objClass->set("symbol",1);
> $objClass->set("size",10);
> $objClass->set("template", "ttt.html");
>
> if ($gbShowQueryResults)
> $img = $gpoMap->drawQuery();
> else
> $img = $gpoMap->draw();
>
> $url = $img->saveWebImage($gAppletImgFmt, 0, 0, -1);
> [...]
>
> I inserted this code to the MSMapDrawMap function of the GMAP demo. This
> new layer will be displayed correctly, but I am not able to query (!)
> objects on this layer :-(
> When I store this map-file with the command:
>
> $gpoMap->save("./test.map");
>
> and open it again and the new point-layer is queryable. Hmmm, what did
> I forget?
> Why do I have to "append" these layers each time when the map will be
> redrawn? Or am I wrong with this presumption...
>
> Thx,
> Rainer
> ---------------------------------------------------------------
> Dipl. Inf. Rainer Spittel
> TZI - Center for Computing Technologies
> Intelligent Systems
> University of Bremen
> Universitaetsallee 21-23, D-28359 Bremen, GERMANY
> Tel: 0421/218-7091 Fax: 0421/218-7196
> E-Mail: mailto:rasp at tzi.de
>
More information about the MapServer-users
mailing list