[Mapserver-users] Making layers in php mapscript
Marcel Koopman
publiek at home.nl
Wed May 5 00:05:02 PDT 2004
Hello,
I cant get php mapscript to create (and show) a layer.
But i want to make layers in php mapscript, instead of retrieving the ones defined in the mapfile.
Here's one layer i have defined in a mapfile:
/**********************************************************************\
LAYER
GROUP "std"
CONNECTIONTYPE postgis
NAME nstudenten
CONNECTION "user=postgres dbname=testdb"
DATA "the_geom from gem_gron_poly"
STATUS off
TYPE POLYGON
TEMPLATE "templates/nstudenten.html"
HEADER "templates/nstudenten_header.html"
FOOTER "templates/nstudenten_footer.html"
DUMP TRUE
PROJECTION
"init=epsg:28992"
END
CLASS
NAME "Aantal studenten 0 - 100"
EXPRESSION ([N_STUDENTEN_ROC] >0 AND [N_STUDENTEN_ROC] <= 100)
COLOR 217 217 255
END
CLASS
NAME "Aantal studenten 100 - 500"
EXPRESSION ([N_STUDENTEN_ROC] >100 AND [N_STUDENTEN_ROC] <= 500)
COLOR 177 177 255
END
CLASS
NAME "Aantal studenten 500 - 1000"
EXPRESSION ([N_STUDENTEN_ROC] >500 AND [N_STUDENTEN_ROC] <= 1000)
COLOR 136 136 255
END
CLASS
NAME "Aantal studenten > 1000"
EXPRESSION ([N_STUDENTEN_ROC] >1000)
COLOR 75 75 255
END
END
/**********************************************************************\
So, this is my php code (groningen-php.map has no layers, i define a new one here in php-mapscript):
-----------------------------------------------------------------------------
$map_path="/var/www/groningen/";
$map = ms_newMapObj($map_path."groningen-php.map");
$layer = ms_newLayerObj($map);
$layer->set(name, $naam);
$layer->set(connectiontype, "postgis");
$layer->set(connection, "user=postgres dbname=testdb");
$layer->set(data, "the geom from gem_gron_poly");
$layer->set(type, MS_POLYGON);
$layer->set(status, MS_ON);
$class = ms_newClassObj($layer);
$class->set(name, "nstudenten");
$class->setexpression("[N_STUDENTEN_ROC] >0 AND [N_STUDENTEN_ROC] <= 100");
$style = ms_newStyleObj($class);
$style->color->setRGB(10,100,10);
$layer_img = $map->prepareimage();
$i = $layer->draw($layer_img);
echo $i;
$layer_url = $layer_img->saveWebImage();
echo "<img src='$layer_img'>";
-----------------------------------------------------------------------------
I cant get a normal image from mapserver. What am i missing?
Thanks for your help.
More information about the MapServer-users
mailing list