adding label to point layer in PHPMapscript
Pietro Giannini
pgiannini at BYTEWISE.IT
Tue Sep 26 09:04:17 PDT 2006
Dear Murat,
the code is ok, the problem seems to be the 'labelitem'
> $koyadi="deneme";
> $point_layer->set("labelitem","$koyadi");
If I set this property the label don't shows,
if I don't set the label shows.
I believe the MS override the labels of the features if we set the label
for the shapes; there is a little difference between 'shape', which is a
geometry joined with a record on a table, and 'feature', which is only a
geometry with, if requested, a label.
Whith the function $layer->addFeature($shape) we add a feature to the layer.
Try & let me know
regards
Pietro
___________________________
Pietro Giannini
Bytewise srl - Area GIS
41°50'38.58"N 12°29'13.39"E
On Mar, 26 Settembre 2006 16:26, Murat BEYHAN disse:
> Dear Pietro;
> Thank you for your suggestion.
> But still the label doesn't appearing
> I have change some point in yor result you sent me..
> Please check it.
> I really try to write label with point by using PHP but I couldn't find
> any
> result on the list archive or on the web.
> Thank you very much for your interest....
> the code which I changed a little are here.....
>
> $map_path="/var/www/html/zone/";
> $map = ms_newMapObj($map_path."zone.map");
> $map->setExtent($nMinX, $nMinY, $nMaxX, $nMaxY);
>
> // create a temp layer to hold our points
> $point_layer = ms_newLayerObj($map);
> $point_layer->set("name", "markers");
> $point_layer->set("type", MS_LAYER_POINT);
> $point_layer->set("status", MS_DEFAULT);
> $point_layer->setProjection("proj=latlong",MS_TRUE);
>
> // create a class and style for this layer
> $point_class = ms_newClassObj($point_layer);
> $point_style = ms_newStyleObj($point_class);
> $koyadi="deneme";
> $point_layer->set("labelitem","$koyadi");
> $point_symbol = $map->getSymbolByName("cpoint");
>
> $point_style->set("symbol", $point_symbol);
> $point_style->set("size", 12);
> $point_style->color->setRGB(255,0,255);
> $point_style->outlinecolor->setRGB(255,255,0);
>
> /* setting a label on the class */
> // $label = $class->label; /***** here also I have changed... as
> follows */
> $label = $point_class->label;
> $label->set("position", MS_CC);
> $label->set("font","arial");
> $label->set("type",MS_BITMAP);/* I HAVE CHANGE THIS LINE BECAUSE
> freetype format doesn't supporting my mapserver. I also try to find a
> solution
> for that.*/
> $label->set("size","large"); /* also hereeeeeeee*/
> $longitude=$lon;// comes from select queries from mysql as a result
> $latitude=$lat;// comes from select queries from mysql as a result
> /* now the method is a bit more complicated as precedent */
> /* create and locate a point object */
> $point = ms_newPointObj(); /* is this will be $point_layer for my
> code???*/
> $point->setXY($longitude, $latitude);
> /* create a line object and add the point */
> $line = ms_newLineObj();
> $line->add($point);
> /* create a shape object and add the mono-point line */
> $shape = ms_newShapeObj(MS_SHAPE_POINT);
> $shape->add($line);
> /* set the "text" property of the shape */
> $shape->set("text","show must go on");
> /* add this shape to the layer */
> $point_layer->addFeature($shape); /* also hereeee*/
>
> /* now you can create the image of the map and save it */
> // $image = $oMap->draw();
> $image = $map->draw();
>
> $map_url=$image->saveWebImage();
> /* you don't need to invoke the */
> // $point->draw($map, $layer, $image, 0, "");
> /**************************************************/
> // draw our image without the points
> $ref = $map->drawreferencemap();
> $legend=$map->drawLegend();
>
>
>
> On Tue, 26 Sep 2006 15:33:08 +0200, Pietro Giannini wrote
>> hi Murat,
>> i tried so, and works:
>>
>> /****************************************/
>> /* setting a label on the class */
>> $label = $class->label;
>> $label->set("position", MS_CC);
>> $label->set("font","arial");
>> $label->set("type",MS_TRUEYPE);
>> $label->set("size",12);
>>
>> /* now the method is a bit more complicated as precedent */
>> /* create and locate a point object */
>> $point = ms_newPointObj();
>> $point->setXY($longitude, $latitude);
>> /* create a line object and add the point */
>> $line = ms_newLineObj();
>> $line->add($point);
>> /* create a shape object and add the mono-point line */
>> $shape = ms_newShapeObj(MS_SHAPE_POINT);
>> $shape->add($line);
>> /* set the "text" property of the shape */
>> $shape->set("text","show must go on");
>> /* add this shape to the layer */
>> $layer->addFeature($shape);
>>
>> /* now you can create the image of the map and save it */
>> $image = $oMap->draw();
>> $map_url=$image->saveWebImage();
>> /* you don't need to invoke the */
>> // $point->draw($map, $layer, $image, 0, "");
>> /**************************************************/
>>
>> best regards
>>
>> Pietro
>>
>> ___________________________
>> Pietro Giannini
>> Bytewise srl - Area GIS
>> 41°50'38.58"N 12°29'13.39"E
>>
More information about the MapServer-users
mailing list