Dear Mike,<br> unfortunally I don't speak PHP! <br><br> ...have not yet used Fusion, but is really good looking!... seems rather complex... I know OL [I used it with Mapserver + WMS], so was a logic choise... don't know how to get map layers' legend yet... if you can give a simple example it would be great... even in PHP, I can read PHP code...<br>
<br>Dear durr,<br><br>OL = OpenLayers, MG = MapGuide [Open Source]<br>there's a name clashing between OL and MG:<br>an OL layer is an MG Map, what in OL is a Base Layer is NOT what in MG is a Base Layer.<br>If the MG Map is made only by Base Layers (MG speaking), you can only toggle the whole think on and off: in Map Guide 2.0 Developer's Guide at page 31 is written:<br>
<br>"<b><i>Layers within a base layer group are rendered together. Visibility settings for<br>individual layers are ignored and the visibility setting for the group is used<br>instead.</i></b>"<br><br>If they are not a BaseLayer, then on server side you must get lay. obj. id:<br>
<br><span style="font-family: courier new,monospace;">string strLID1 = mgMap.GetLayers().GetItem("*LAYER
NAME 1*").GetObjectId()</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">...</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">string strLIDN = mgMap.GetLayers().GetItem("*LAYER
NAME N*").GetObjectId()</span><br style="font-family: courier new,monospace;"><br>[...I think we should not use above code in c#, but make a variable for each object and despose it... there's no documentation on what must and what must not be disposed...]<br>
Now suppose that from above code you get the following layer object ids:<br><span style="font-family: courier new,monospace;">strLID1=="id1"</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">...</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">strLIDN=="idN"</span><br><br>and that <br>"<span style="font-family: courier new,monospace;">id_s1", ... "id_sk" </span> are the one you want to show<br>
<span style="font-family: courier new,monospace;">"id_h1,..., "id_hu" <span style="font-family: arial,helvetica,sans-serif;">are the one you want to hide</span></span><br><br>Indices <br><span style="font-family: courier new,monospace;"> s1,...,sk in J={1,...,n}</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> h1,...,hu in [{1,...,n} - J]</span><br style="font-family: courier new,monospace;">...ok is not very comprehensible: say we have some layers to show with id "id_s1", ... "id_sk" and some to hide "id_h1",..., "id_hu".<br>
<br>Now YOU HAVE TO FIND A WAY TO PASS THEM TO CLIENT depending on the server side language of your chise [note that they will not be valid any more on MG session expiration!!!]<br><br>On client something <b><i>like</i></b>:<br>
<br><span style="font-family: courier new,monospace;">var _mgLayer = null;</span><br><span style="font-family: courier new,monospace;">var ccc=0;</span><br><br><span style="font-family: courier new,monospace;">function someFunc() {</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><div style="margin-left: 40px;"><span style="font-family: courier new,monospace;">(...)</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">var map = new Openlayers.Map(........);</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">var baseLayer = (...); <i>//without a Base Layer (OL speaking) you will not get OL correctly init</i></span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">var url = "<i>something like /mapguide/mapagent/mapagent.fcgi?USERNAME=Anonymous&</i>";</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">var mgOptions = {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> <b>singleTile: true</b>,</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> buffer: 1,</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> session</span>:<span style="font-family: courier new,monospace;"> "session id taken from server"</span>,<br>
<font face="courier new,monospace"> mapDefinition: "map def, <i>better</i> from server" [ex.:"Library://Samples/Sheboygan/MapsTiled/Sheboygan.MapDefinition</font>"]<br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> };</span><br style="font-family: courier new,monospace;"><b><span style="font-family: courier new,monospace;">var params = {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> showLayers: "id_k1,...,id_sk", //CSV of layer ids to show</span> - taken FROM SERVER!<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> hideLayers: "id_h1,...,id_hu" //CSV of layer ids to hide - </span>taken FROM SERVER!<br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">};</span><br style="font-family: courier new,monospace;"></b><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"></span><span style="font-family: courier new,monospace;">_mgLayer </span><span style="font-family: courier new,monospace;">= new OpenLayers.Layer.MapGuide("custom lay. name", url, params, mgOptions);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">map.addLayer(mgOverlayLayer);</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">(...)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> </span><br style="font-family: courier new,monospace;"></div>
<span style="font-family: courier new,monospace;">}//end someFunc</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">function swapHideShow()</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">{</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> if(mgOverlayLayer)<br> {<br> if(ccc++%2==0)<br> {<br> _mgOverlayLayer.params.showLayers = "id_h1,...,id_hu";<br>
_mgOverlayLayer.params.hideLayers = "id_k1,...,id_sk";<br> }<br> else<br>
{<br>
_mgOverlayLayer.params.showLayers = "id_k1,...,id_sk";<br>
_mgOverlayLayer.params.hideLayers = "id_h1,...,id_hu";<br>
}<br> </span><span style="font-family: courier new,monospace;">_mgLayer</span><span style="font-family: courier new,monospace;">.redraw(true);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> }<br>
}</span><br><br>Bye, <br> P.I.<br>