Hi Dominic, <br><br>Here&#39;s a little snipit i&#39;ve thrown together that should accomodate your request. Although it&#39;s untested it would be a good start to doing this. <br><br>How it works is: <br><br>You have two mapfiles. One is your application which is loaded in the fusion AppDef and the other is a mapfile that has all the layers you wish to add.<br>
<br>This &quot;catalogue&quot; map file is what this code will search through to find the layer requested by the user <br><br>These javascript functions are to be included in your applications template code. and the php script can be placed anywhere in the applications web accessible folder. <br>
<br>You simply call the javascript function addCatalogLayer() with the layername as it is specified in the catalogue map file and it will search through it and add it to the active sessions mapfile and reload the map from the callback. <br>
<br>Note I&#39;ve wipped this together from another application i&#39;ve worked on with out testing it at all so there may be errors. :)<br><br>Hope this helps. <br><br>Cheers<br><br>Paul D. <br><br>-- <br>    Paul Deschamps<br>
    Applications Specialist<br>    DM Solutions Group Inc.<br><br>    Office: (613) 565-5056 x28<br>    <a href="mailto:pdeschamps@dmsolutions.ca">pdeschamps@dmsolutions.ca</a><br>    <a href="http://www.dmsolutions.ca">http://www.dmsolutions.ca</a><br>
    <a href="http://research.dmsolutions.ca">http://research.dmsolutions.ca</a><br><br>&lt;?<br>// BEGIN PHP CODE SNIPIT -----------------------------<br><br>// path to fusion root<br>define(&#39;FUSION_ROOT&#39;,&#39;/opt/fgs/apps/fusion&#39;);<br>
// path to a valid mapserver mapfile with all the layers we are going to allow the user to add.<br>define(&#39;APP_LAYER_CATALOG&#39;,&#39;/opt/fgs/apps/fusion/layers.map&#39;);<br><br>include FUSION_ROOT.&quot;/mapserver/php/Common.php&quot;;<br>
include FUSION_ROOT.&quot;/common/php/Utilities.php&quot;;<br><br>if (!isset($mapName)) {<br>    die(&#39;mapname not set&#39;);<br>}<br>// defaults to false<br>$szObject-&gt;addedLayer = false;<br><br>if (isset($_SESSION[&#39;maps&#39;]) &amp;&amp; isset($_SESSION[&#39;maps&#39;][$mapName])) {<br>
    $szObject = addLayer($_REQUEST[&quot;layername&quot;]);<br>}<br><br>$szJsonData =  var2json($szObject);<br>header(&#39;Content-type: text/plain&#39;);<br>header(&#39;X-JSON: true&#39;);<br>echo $szJsonData;<br><br>function addLayer($szValue){<br>
    global $mapName;<br><br>    $oReturn-&gt;addedLayer = false;<br><br>    // open up the session mapfile.<br>    $oMap = ms_newMapObj($_SESSION[&#39;maps&#39;][$mapName]);<br>    // open up the catalogue map file.<br>    $oCatalogMapFile = ms_newMapObj(APP_LAYER_CATALOG);<br>
<br>    // loop through the catalogue mapfile.<br>        for($i = 0; $i &lt; $oCatalogMapFile-&gt;numlayers; $i++){<br>        // get the layer<br>        $oLayer = $oCatalogMapFile-&gt;getLayer( $i );<br>        // did we find the layer by it&#39;s layername.<br>
        if($oLayer-&gt;name == $szValue){<br>            //found layer add it to the session mapfile.<br>            ms_newLayerObj( $oMap, $oLayer );<br>            // return true<br>            $oReturn-&gt;addedLayer = true;<br>
            }<br>        }<br>    // save map file if we&#39;ve added a layer.<br>    if($oReturn-&gt;addedLayer == true){<br>        // save the session mapfile.<br>        $oMap-&gt;save($_SESSION[&#39;maps&#39;][$mapName]);<br>
    }<br>    return $oReturn;<br>}<br>// END PHP CODE SNIPIT -----------------------------<br>?&gt;<br>&lt;!-- BEGIN JAVASCRIPT CODE SNIPIT ----------------------------- --&gt;<br>// place this javascript in your application template.<br>
&lt;script language=&quot;javascript&quot;&gt;<br>function addCatalogLayer(szLayerName){<br>    var s = pathToAddLayer + &quot;addLayer.php&quot;;<br>    var mapWidget = Fusion.getMapById(&#39;mapArea&#39;);<br>    var maps = mapWidget.getAllMaps();<br>
    var map = maps[0];<br><br>    var session = &#39;session=&#39;+map.getSessionID();<br>    var mapName = &#39;&amp;mapname=&#39;+ map._sMapname;<br>    var layername     = &#39;&amp;layername=&#39;     +szLayerName;<br>
<br>    var params = session+mapName+layername;<br>    var opts = {parameters: params, onComplete: addCatalogLayerCB.bind(null)};<br>    Fusion.ajaxRequest(s, opts);<br>}<br>/*<br>function addCatalogLayerCB - CB func from addCatalogLayer. The Layer is now added to mapfile,<br>
                             if o.addedLayer = true else something when wrong.<br>*/<br>function addCatalogLayerCB(r){<br>    var o = &#39;&#39;;<br>    eval(&#39;o=&#39;+r.responseText);<br><br>        if(o.addedLayer == true){<br>
          var map = Fusion.getMapById(&#39;mapArea&#39;);<br>          var maps = map.getAllMaps();<br>          maps[0].reloadMap();<br>        } else {<br>            alert(&#39;addCatalogLayerCB:could not add layer&#39;);<br>
        }<br>}<br>&lt;/script&gt;<br>&lt;!-- END JAVASCRIPT CODE SNIPIT ----------------------------- --&gt;<br><br><br><br><div class="gmail_quote">On Mon, Jun 15, 2009 at 4:17 PM, Dominic Gervais <span dir="ltr">&lt;<a href="mailto:dominicgervais@hotmail.com">dominicgervais@hotmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">



<div>
 <br>
Hello All fusion users....<br>
 <br>
Is there a way of adding a layer to the mapfile using PHP/MapScript. I&#39;d like to enpower users so they can choose to add a layer of their choice to a &quot;base&quot; Mapfile. So, scaling is out of the question.<br>
 <br>
I know I can add some code in the loadMap.php file. But, is it possible to retrieve some variables in that file that would be submitted by the user prior to accessing the index.html (or index.php in my case) via a form of some sort.<br>

 <br>
Any hints would be appreciated...<br>
 <br>
Thanks,<br>
 <br>
Dominic<br><br><hr>Windows Live helps you keep up with all your friends,  <a href="http://go.microsoft.com/?linkid=9660824" target="_blank">in one place.</a></div>
<br>_______________________________________________<br>
fusion-users mailing list<br>
<a href="mailto:fusion-users@lists.osgeo.org">fusion-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/fusion-users" target="_blank">http://lists.osgeo.org/mailman/listinfo/fusion-users</a><br>
<br></blockquote></div><br><br clear="all"><br>    <br><br>