Dynamically Adding Labels... Please Help!!

Stephen Woodbridge woodbri at SWOODBRIDGE.COM
Tue Apr 19 23:59:55 EDT 2005


mike bockus wrote:
> I'm using the PHP extension and I'm attempting to add
> a label given a longitude and latitude to a map.  The
> label text will be taken from user input in our web
> application.  I've searched for over two days without
> finding a solution.  Any help would be greatly
> appreciated.  Thanks.
>
>
> I've tried the following but failed...
> $pt = ms_newLineObj();
> $pt->addXY(35,50); // do x and y represent latitude
> and longitude?

NO, x=longitude y=latitude unless you are using some projection

> $shape = ms_newShapeObj(MS_SHAPE_POINT);
> $shape->set('classindex', 0);
> $shape->set('text', "Testing");  // assign the label
> $shape->add($pt);
> $layer = $map->getLayerByName('line_annotation');

try adding:
   $layer->set("status", MS_ON);

> $test=$layer->addFeature($shape);
> $shape->draw($map, $layer, $map->draw());
> $image = $map->draw();
>
> Here's the mapfile for line_annoatation
> LAYER
>    NAME line_annotation
>    STATUS ON
>    TYPE ANNOTATION
>    FEATURE
>    END
>    CLASS
>      LABEL
>        TYPE TRUETYPE
>        FONT arial
>        SIZE 10
>        COLOR 0 0 0
>        POSITION UC
>        FORCE TRUE
>      END
>    END
> END
>
> Thanks again.
>
>
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail - Helps protect you from nasty viruses.
> http://promotions.yahoo.com/new_mail
>



More information about the mapserver-users mailing list