[Mapserver-users] PhpMapScript and Labels

Eric Bridger eric at gomoos.org
Fri Jun 13 04:17:26 PDT 2003


Jaroslaw,
You need to add the label text to your shape before your call to
addFeature.

$newshapeObj->{text} = $my_label_text;

Sorry this is Perl syntax. In PHP it might be
$newshapeObj->set('text', $my_label_text); but I'm not sure.



On Fri, 2003-06-13 at 08:54, Jaroslaw Kowalczyk wrote:
> Hello,
> 
> Maybe someone could help with my probelm. I would like to display labels
> using phpmapscript. First I create Layer, Class and than add shapes form
> dynamically created shapefile. Shapefile is based on data I store in mySQL
> database.
> 
> Although this new layer appears correctly (red symbols + black outlines)
> labels does not appear at all. What is wrong with my code (bellow)?
> 
> Thank you.
> Jaroslaw Kowalczyk
> 
> //----------------------------------
>  $newLayer=ms_newLayerObj($map);
>  $newLayer->set(status,MS_ON);
>  $newLayer->set(name,"Oferty");
>  $newLayer->set(type,MS_LAYER_POINT);
>  $newLayer->set(labelitem,"id_oferty");
>  $newClass=ms_newClassObj($newLayer);
>  $newClass->set(symbol,4);
>  $newClass->set(size,15);
>  $newClass->set(color,$map->addColor(255, 0, 0));
>  $newClass->set(outlinecolor,$map->addColor(0, 0, 0));
>   $newClass->{label}->{position}=MS_CC;
>   $newClass->{label}->set(color, $map->addColor(0, 0, 0));
>   $newClass->{label}->{font}=fritqat;
>   $newClass->{label}->{type}=truetype;
>   $newClass->{label}->{size}=5;
>   $newClass->{label}->{antialias}=true;
> 
> $shapefile_temp=ms_newShapefileObj("c:/usr/krasnal/www/edeveloper/map/htdocs
> /data/".$shapetempname,-1);
>   $l_ofert=$shapefile_temp->{numshapes};
>       for ($i=0;($i<$l_ofert);$i++)
>       {
>          $newShapeObj=ms_newShapeObj(MS_SHAPE_POINT);
>        $newShapeObj=$shapefile_temp->getShape($i);
>        $newLayer->addFeature($newShapeObj);
>        $newShapeObj->free();
>       }
>       $shapefile_temp->free();
> 
> 
> 
> 
> ---------------------------
> Jaroslaw Kowalczyk
> www.ekoprojekt.pl
> 
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users at lists.gis.umn.edu
> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
> 





More information about the MapServer-users mailing list