Adding shapefile dynamically with php_mapscript 4.4.2

Jacob Delfos jacob.delfos at MAUNSELL.COM
Mon Jun 13 20:48:44 PDT 2005


Steve,

Thanks for the suggestion. I thought about this approach, but since this is for a chameleon widget, it needs to be "drop-in" functionality, without having to make changes to the mapfile. It's a bit "cleaner" that way, although apparently more complex.

regards,

Jacob

-----Original Message-----
From: Stephen Woodbridge [mailto:woodbri at swoodbridge.com] 
Sent: 14 June 2005 11:03
To: Jacob Delfos
Cc: MAPSERVER-USERS at LISTS.UMN.EDU
Subject: Re: [UMN_MAPSERVER-USERS] Adding shapefile dynamically with php_mapscript 4.4.2

Jacob,

The way I do this is to create a normal in the mapfile with the STATUS 
OFF and no DATA statement. Then in mapscript all I do it set the STATUS 
ON and assign the path to the DATA like you are doing below.

It is MUCH easier to create a template layer in the mapfile and then 
manipulate it, rather than creating the whole thing from scratch.

YMMV,
   -Steve W.

Jacob Delfos wrote:
> Hi All,
>  
> I am trying to dynamically add a shapefile which I created at runtime. 
> The shapefile is created successfully (it opens up ok). But I am not 
> having any luck adding it as a layer.
>  
> This is the code I have:
>  
>       $queryResultlayer = ms_newLayerObj( $oMap );
>       $queryResultlayer->set( "name", "Queryresult" );
>       $queryResultlayer->set( "type", $shapetype );
>       $queryResultlayer->set( "status", MS_ON );
>       $queryResultlayer->set( "data", 
> $szSessionDir."/queryResultShapefile");
>       $queryResultlayer->set( "template", "ttt" );
>       $queryResultlayer->set( "tolerance", 5 );
>       $queryResultlayer->set( "toleranceunits", MS_PIXELS);
>       $queryResultlayer->setProjection($mapprojection);
>       $queryclass = ms_newClassObj($queryResultlayer);
>       $queryclass->set("name", "Query result");
>       $queryclass->set("status", MS_ON);
>       $style = ms_newStyleObj($queryclass);
>       $style->color->setRGB(255, 255, 0);
>       $style->outlinecolor->setRGB(255, 0, 0);
>  
> The layer is not showing (extents of map are correct). I am not getting 
> any errors either. The temporary mapfile being created in the session 
> directory does not contain my layer. Am I missing something?
>  
> The $oMap object is a reference to the $oMap from the session (using 
> Chameleon). I am loading the session from an Iframe, and creating the 
> $oMap object like:
>  
> $oMap =& $oMapSession->oMap;
>  
> So if I add a layer to the map object, the layer should show if the map 
> image is reloaded in the main frame, right?
>  
> Any help would be much appreciated.
>  
> Regards,
>  
> Jacob
>  
> 
> JACOB DELFOS
> SPATIAL INFORMATION ANALYST
> Maunsell Australia Pty Ltd
> 629 Newcastle Street, Leederville, WA 6007
> PO Box 81, Leederville, WA 6902
> Western Australia
> ABN 20 093 846 925
>  
> Tel     + 61 8 9281 6185
> Fax    + 61 8 9281 6297
> jacob.delfos at maunsell.com <mailto:jacob.delfos at maunsell.com>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20050614/a0d5366c/attachment.htm>


More information about the MapServer-users mailing list