PHPMapscript : PointObj->draw(...) problem

Stéphane RIFF stephane.riff at CERENE.FR
Mon Jan 15 10:52:57 EST 2007


Hi everybody,

I have a little problem on the draw function with the pointObj class.
I want to add point dynamically from a postgis database with PHPMapscript.
So I get the coordinates from postgis and draw the point with 
pointObj->draw(...) function.
The problem is that my pixmap symbols doesn't have the transparency 
activated and my label doesn't have background color.

I use the code below :
 
$mobileLayer = ms_newLayerObj($map);
$mobileLayer->set("name","Mobiles");
$mobileLayer->set("type",MS_LAYER_POINT);
$mobileLayer->set("status",MS_ON);
$mobileLayer->set("transparency",MS_GD_ALPHA);
$mobileLayer->set("labelcache",MS_OFF);
$mobileLayer->setProjection("init=epsg:4326",MS_TRUE);
       
$a_class = array();
for($row=0;$row<pg_num_rows($result);$row++)
{
  $lon = pg_fetch_result($result,$row,0);
  $lat = pg_fetch_result($result,$row,1);
  $ico = pg_fetch_result($result,$row,2);
  $sid = pg_fetch_result($result,$row,3);
           
  if(!in_array($ico,$a_class))
  {
    array_push($a_class,$ico);
    $mobileClass = ms_newClassObj($mobileLayer);
    $mobileClass->set("name",$ico);
    $mobileStyle = ms_newStyleObj($mobileClass);
    $mobileStyle->set("symbolname",$cfg_root."images/symbols/".$ico);
    $mobileLabel = $mobileClass->label;
    $mobileLabel->set("font","Arialbd");
    $mobileLabel->set("size",12);
    $mobileLabel->set("type",MS_TRUETYPE);
    $mobileLabel->set("offsety",-22);
    $mobileLabel->color->setRGB(255,0,0);
    $mobileLabel->backgroundcolor->setRGB(255,0,0);
  }
           
  $class_index = 0;
  for($cl=0;$cl<$mobileLayer->numclasses;$cl++) {
    $class = $mobileLayer->getClass($cl);
    if($class->name == $ico) {
      $class_index = $cl;
   }
 }
 $point = ms_newPointObj();
 $point->setXY($lon,$lat);
 if($point->draw($map, $mobileLayer, $imgObj, $class_index, $sid) == 
MS_FAILURE)
   print("error drawing point");
}

The result image is like that the one attached :

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Clipboard01.gif
Type: image/gif
Size: 5527 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/mapserver-users/attachments/20070115/e3149f38/Clipboard01.gif


More information about the mapserver-users mailing list