PHP/MapScript: getLayerByName()

Bart van den Eijnden (OSGIS) bartvde at XS4ALL.NL
Fri May 5 06:19:45 EDT 2006


Hi,

you need to have a MapObj based on your MAP file. On your MapObj you can 
call getLayerByName.

See the example here:
http://mapserver.gis.umn.edu/docs/reference/phpmapscript-class/referencemanual-all-pages

        example of usage :

           $map = ms_newmapobj("d:/msapps/gmap-ms40/htdocs/gmap75.map");
           $layer = $map->getLayerByName('road');

Best regards,
Bart

DjwStone wrote:

>I'm taking first faltering steps with PHP/MapScript so forgive if following
>question is dumb.
>
>A la classic MapServer tutorial example, I'm building an interactive map
>form which allows pan/zoom/layer selection. It's the last of these that's
>giving me difficulty.
>
>The HTML defines a select list of layers:
>
>   <SELECT MULTIPLE NAME="layers[]" SIZE=3>
>   <!-- the list of layers to choose from -->
>     <OPTION VALUE="parish_labels"> Parish names</OPTION>
>etc.,....
>
>When the form is submitted, the PHP should tell MapServer which elements in
>the list were selected. My code is:
>
>function retrieve_select(){
>   for ($r=0; $r <= count($_POST['layers'])-1; $r++){
>       // echo $_POST['layers'][$r]."<BR>";
>       $my_layer=getLayerByName($_POST['layers'][$r]);
>       $i = $my_layer->set($my_layer->status, MS_ON);
>   }
>}
>
>However, PHP reports 'Call to undefined function getLayerByName()'. Since I
>found the function in the PHP/MapScript Class Reference document, I'm
>wondering if this is a deliberately misleading error message?!
>
>Any help gratefully acknowledged...
>
>Dave
>
>
>--
>View this message in context: http://www.nabble.com/PHP-MapScript%3A-getLayerByName%28%29-t1562941.html#a4244464
>Sent from the Mapserver - User forum at Nabble.com.
>
>
>  
>


-- 
Bart van den Eijnden
OSGIS, Open Source GIS
http://www.osgis.nl



More information about the mapserver-users mailing list