[mapserver-users] Mixed Mapfile and Mapscript (php)

Yewondwossen Assefa assefa at dmsolutions.ca
Mon Jun 24 07:05:35 PDT 2002


Hi There,

 The way to set the colors in mapscript is :

   * add a color in the map object : $colorindex = $map->addcolor(r, g, b)

   * use the color index in your class setting : class->set("color",
$colorindex)

  Hope it helps,


Erich Schroeder wrote:

> Hi,
>   I'm trying to set up a php mapscript application in which I have a
> standard bunch of base layers in a standard base file (these draw just
> fine) but then I want to dynamically add additional point layers which are
> based on what shapefiles are present. I was wondering if anyone has some
> example code for what is needed for adding in and displaying a new layer?
>
> I'm probably missing something simple that I will find right after I send
> this, but the current code looks like:
>
> $map = ms_newMapObj("base.map");
> //find what files are present in the folder for a particular taxon
> $AgesPresent = GetAges($Taxon);
> //set some path stuff
> $TaxonPath = "$FaunmapPath/data/$TaxonLower";
> foreach ($AgesPresent as $key=>$age) {
>   $layer = ms_newLayerObj($map);
>   $layer->set(data,"data/$taxon/$age.shp");
>   $layer->set(name,$age);
>   $layer->set(type,"point");
>   $layer->set(classitem,"sitenum");
>   $layer->set(status,"MS_DEFAULT");
>   $class =  ms_newClassObj($layer);
>   $class->set(name,strtoupper($age));
>   $class->set(symbol,"circle");
>   $class->set(size,7);
>   $class->set(color,"7 27 249");
> }
> $img = $map->draw();
> $url = $img->saveWebImage(MS_PNG, 0, 0, 0);
> printf("<img src=%s width=%d height=%d>\n", $url, $map->width,
> $map->height);
>
> It seems to correctly add the layers (numbering in 1-15 depending on the
> taxon), but I'm not seeing it. I'm sure that there is something wrong with
> the color setting, and I suppose I need a "draw" statement, but I don't
> see a clear description in any of the documentation or examples I have
> found so far.
>
> Erich
>
> --
> ---------------------------------------------------------------------
> Erich Schroeder                    Phone: (217)785-0033
> Curator, Information Technologies  FAX:   (217)785-2857
> Illinois State Museum GIS Lab      email:erich(at)illinois.state.museum
>                  http://illinois.state.museum/
> ---------------------------------------------------------------------

--
----------------------------------------------------------------
Assefa Yewondwossen
Software Analyst

Email: assefa at dmsolutions.ca
http://www.dmsolutions.ca/

Phone: (613) 565-5056 (ext 14)
Fax:   (613) 565-0925
----------------------------------------------------------------





More information about the MapServer-users mailing list