[mapserver-users] PHP mapscript: drawing labels as top layer

Daniel Morissette morissette at dmsolutions.ca
Fri Nov 29 14:13:11 EST 2002


Jim,

Have you considered looping through all layers to draw each one in turn,
then drawing your shape, and finally drawing the label cache:

  $img = $this->mapObject->prepareImage();
  for($i=0; $i<$this->mapObject->numLayers; $i++)
  {
    $layer = $this->mapObject->getLayer($i);
    $layer->draw($img);
  }

  // My own method to get a particular shape
  $Layer = ...
  $Shape = $this->getShape();
  $Shape->draw($this->mapObject, $Layer, $img);
  
  $this->mapObject->drawLabelCache($img);
  

Daniel
-- 
------------------------------------------------------------
 Daniel Morissette               morissette at dmsolutions.ca
 DM Solutions Group              http://www.dmsolutions.ca/
------------------------------------------------------------



Jim Sproull wrote:
> 
> Hi all,
> 
>  I'm developing a mapscript application using the latest (3.6.3) version
> of mapserver with the php module.  I'm trying to perform the fairly
> basic function of drawing a map, followed by assigning a custom colour
> to a particular shape, followed by all relevant labels (from the label
> cache).  Unfortunately, it seems no matter what I do, the shape always
> sits on top of the labels.  Here's the general idea:
> 
> // $this->mapObject is predefined
> $imgObj = $this->mapObject->prepareImage();
> 
> // My own method to get a particular shape
> $Shape = $this->getShape();
> $Shape->draw($this->mapObject, $Layer, $imgObj);
> 
> $this->mapObject->drawLabelCache($imgObj);
> 
> $mapImage = $this->mapObject->draw();
> $mapImage->pasteImage($imgObj, 0);
> 
> This always pastes the shape object over the labels.  If I draw the map
> object first, then draw the shape, then finally the label cache, it
> works. However that method draws the labels twice, and almost doubles
> the processing time.  Is there a way to draw the proper layer order
> without duplicating labels?
> 
> --
> Jim Sproull <sproull.j at emstechnologies.ca>
> EMS Technologies



More information about the mapserver-users mailing list