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

Lowell Filak lfilak at medinaco.org
Mon Jun 24 08:58:14 EDT 2002


It's not a php example, but there are perl examples of adding points & shapes to a layer at:
http://mapserver.gis.umn.edu/cgi-bin/wiki.pl?PerlMapScriptExamples35ex2
&
http://mapserver.gis.umn.edu/cgi-bin/wiki.pl?PerlMapScriptExamples35ex9
Possibly you can use those to at least decode the steps required.
One other thing to check is - if you are creating a dynamic shapefile (which doesn't appear the case from the code) be sure that the dbf file to go with it is created also.
Lowell F.

The following message was sent by Erich Schroeder <erich at museum.state.il.us> on Sun, 23 Jun 2002 16:01:05 -0500 (CDT).

> 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/
> ---------------------------------------------------------------------




More information about the mapserver-users mailing list