AW: [UMN_MAPSERVER-USERS] Dynamic points and labels

Frank Broniewski Frank.Broniewski at MNHA.ETAT.LU
Tue Nov 22 00:18:51 PST 2005


Hello

I think you need to draw the label cache before drawing your map image.
I append my code, so you can see, what I do:

            foreach($this->session->get('points') as $points) {
        		$myXY = ms_newPointObj();
        		$myXY->setXY($points['x'], $points['y']);
        		$dummylayer =
$this->map->getLayerByName('DummyPoint');
        		$success = $myXY->draw($this->map, $dummylayer,
$mapimage, $points['class'], $points['label']);
            }
            $this->map->drawLabelCache($mapimage);

                                                      
Frank Broniewski
Musée National d'Histoire et d'Art
Section Préhistoire / Projet EPC
    Tél: +352 260 281-21
241, Rue de Luxembourg
L-8077 Bertrange


-----Ursprüngliche Nachricht-----
Von: UMN MapServer Users List [mailto:MAPSERVER-USERS at LISTS.UMN.EDU] Im
Auftrag von dldeskins at GMAIL.COM
Gesendet: Montag, 21. November 2005 22:08
An: MAPSERVER-USERS at LISTS.UMN.EDU
Betreff: [UMN_MAPSERVER-USERS] Dynamic points and labels


I have written a function that is used place points dynamically on a map
from session variables:  function addPoints(&$map,&$image,$xCoor,$yCoor,
$symbol, $text)  {
  $my_layer = ms_newLayerObj($map);
  $my_layer->set("name", "myLayer");
  $my_layer->set("type", MS_LAYER_POINT);
  $my_layer->set("status", MS_ON);

  $my_layer->set(transparency, 75);
  $pt = ms_newPointObj();
  $ln = ms_newLineObj();
  $shp = ms_newShapeObj(MS_SHAPE_POINT);
  // these are pixel coordinates because TRANSFORM is FALSE

  $pt->setXY($xCoor, $yCoor);
  $ln->add($pt);
  $shp->add($ln);

  $my_class = ms_newClassObj($my_layer);
  $my_class->label->set("font", "arial-bold");
  $my_class->label->set("type", MS_TRUETYPE);
  $my_class->label->set("size", 7);
  $my_class->label->color->setRGB(255, 0 , 0);
  $my_class->label->backgroundcolor->setRGB(255, 255 , 255);
  $my_class->label->set("position", MS_LC);
  $my_class->label->set("force", MS_TRUE);

  $my_class->label->set("partials", MS_TRUE);
  $my_class->label->set("buffer", 0);
  $shp->set("text", stripslashes($text));

  $my_style = ms_newStyleObj($my_class);

  if($symbol == "g")
  {
   $my_style->set("symbolname","star_green");
  }
  elseif($symbol == "b")
  {
   $my_style->set("symbolname","star_blue");
  }

  $my_layer->addFeature($shp);
  $my_layer->draw($image);

 }

The symbols are showing in the proper place. The problem that I am
having is that the label will not show. Can anyone see a problem with
the function?  I would eventually like to set the font, color, size
dynamically also.

Thanks



More information about the MapServer-users mailing list