<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
<META content="MSHTML 6.00.2900.3676" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff 
size=2></FONT>&nbsp;</DIV><FONT face=Arial color=#0000ff size=2></FONT><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> VOLZ Mark (FN) <BR><B>Sent:</B> Wednesday, 
2 June 2010 2:21 PM<BR><B>To:</B> 
'mapguide-internals@lists.osgeo.org'<BR><B>Subject:</B> Problem with programatic 
changes of layers<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=779085103-02062010>Folks,</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=779085103-02062010></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2><SPAN class=779085103-02062010>I'm using the MGE 
2010 (using a basic web layout) and&nbsp;I am having some problems when I 
modifiy a layer via a piece of php (and I'm not getting much joy from 
ADSK).</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=779085103-02062010></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2><SPAN class=779085103-02062010>The 
scenerio;</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=779085103-02062010></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2><SPAN class=779085103-02062010>1) From another app 
the user launches a mapguide session&nbsp;via a url call which contains a unique 
id for the particualar piece of plant they wish to view i.e. </SPAN></FONT><FONT 
face=Arial size=2><A 
href="http://<server_name>/mapguide2010/feederstat/navnet-switchzone.php?ParentId=60005615">http://&lt;server_name&gt;/mapguide2010/feederstat/navnet-switchzone.php?ParentId=60005615</A></FONT></DIV>
<DIV><SPAN class=779085103-02062010><FONT face=Arial size=2>2) The 
navnet-switchzone.php creates&nbsp;and logs into&nbsp;a mapguide 
session.</FONT></SPAN></DIV>
<DIV><SPAN class=779085103-02062010></SPAN><SPAN class=779085103-02062010><FONT 
face=Arial size=2>3) This page then calls another page&nbsp;passing the 
ParentID, session id, &amp; mapname variables. </FONT></SPAN><SPAN 
class=779085103-02062010><FONT face=Arial size=2></FONT></SPAN></DIV>
<DIV><SPAN class=779085103-02062010><FONT face=Arial size=2>4) The second page 
has 2 functions firstly to set a layer filter and secondly to make that layer 
invisible in the layer legend.</FONT></SPAN></DIV>
<DIV><SPAN class=779085103-02062010><FONT face=Arial size=2>5) The first page 
then zooms to the extents as calculated via an mbr query on Oracle 
spatial.</FONT></SPAN></DIV>
<DIV><SPAN class=779085103-02062010><FONT face=Arial 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=779085103-02062010><FONT face=Arial size=2>Simple 
enough.</FONT></SPAN></DIV>
<DIV><SPAN class=779085103-02062010><FONT face=Arial 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=779085103-02062010><FONT face=Arial size=2>My problem is the 
second action of the second php page i.e. setting the layer to invisible in the 
layer legend. It does do it after the user performs a zoom or pan command but it 
is&nbsp;in the layer legend&nbsp;when the page first loads which I don't 
want.</FONT></SPAN></DIV>
<DIV><SPAN class=779085103-02062010><FONT face=Arial 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=779085103-02062010><FONT face=Arial size=2>Things I have 
tried;</FONT></SPAN></DIV>
<DIV><SPAN class=779085103-02062010><FONT face=Arial 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=779085103-02062010><FONT face=Arial size=2>1) Adding the layer 
to the library map with the filter set to -1 and&nbsp;turning off the&nbsp;layer 
legend visiblity. - no luck</FONT></SPAN></DIV>
<DIV><SPAN class=779085103-02062010><FONT face=Arial><FONT size=2>2) doing a 
second zoom when the page is first loaded i.e. log into the seession zoom to a 
scale of (truescale * 1.1) modify the layer then zoom to true scale. - no 
luck<SPAN class=121331805-02062010><FONT 
color=#0000ff>&nbsp;</FONT></SPAN></FONT></FONT></SPAN></DIV>
<DIV><SPAN class=779085103-02062010><FONT face=Arial><FONT size=2><SPAN 
class=121331805-02062010>3) &nbsp;After page loads running the ForceRefresh() 
command</SPAN></FONT></FONT></SPAN></DIV>
<DIV><SPAN class=779085103-02062010><FONT face=Arial 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=779085103-02062010><FONT face=Arial size=2>Any 
ideas?</FONT></SPAN></DIV>
<DIV><SPAN class=779085103-02062010><FONT face=Arial 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=779085103-02062010><FONT face=Arial size=2>Below is the code i 
am using to modify the layer.</FONT></SPAN></DIV>
<DIV><SPAN class=779085103-02062010><FONT face=Arial 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=779085103-02062010><FONT face=Arial size=2>Any help would be 
greatly appreciated.</FONT></SPAN></DIV>
<DIV><SPAN class=779085103-02062010><FONT face=Arial 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=779085103-02062010><FONT face=Arial 
size=2>Mark</FONT></SPAN></DIV>
<DIV><SPAN class=779085103-02062010><FONT face=Arial 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=779085103-02062010><FONT face=Arial size=2>// change&nbsp; 
HV_isol_dev_parent layer<BR>&nbsp;$resId = new 
MgResourceIdentifier('Library://FeederStat/Layers/HV_isol_dev_parent.LayerDefinition');<BR>&nbsp;$byteReader 
= $resourceService-&gt;GetResourceContent($resId);<BR>&nbsp;$layerXML = 
$byteReader-&gt;ToString();<BR>&nbsp;$doc = 
DOMDocument::loadXML($layerXML);<BR>&nbsp;$GridNode = 
$doc-&gt;getElementsByTagName('GridLayerDefinitionType');<BR>&nbsp;$FilterNode = 
$doc-&gt;getElementsByTagName('Filter');<BR>&nbsp;$FilterNode-&gt;item(0)-&gt;nodeValue 
= "ECORP_ASSET_ID = ".$parentId;</FONT></SPAN></DIV>
<DIV>&nbsp;</DIV>
<DIV><SPAN class=779085103-02062010><FONT face=Arial 
size=2>&nbsp;$LayerDefinition = $doc-&gt;saveXML();<BR>&nbsp;$byteSource = new 
MgByteSource($LayerDefinition, 
strlen($LayerDefinition));<BR>&nbsp;$byteSource-&gt;SetMimeType(MgMimeType::Xml);</FONT></SPAN></DIV>
<DIV>&nbsp;</DIV>
<DIV><SPAN class=779085103-02062010><FONT face=Arial 
size=2>&nbsp;$layerName="HV_isol_dev_parent";<BR>&nbsp;$sessionLayer = 
"Session:".$sessionId."//".$layerName.".LayerDefinition";<BR>&nbsp;$sessResId = 
new&nbsp; 
MgResourceIdentifier($sessionLayer);<BR>&nbsp;$resourceService-&gt;SetResource($sessResId, 
$byteSource-&gt;GetReader(),&nbsp; null);</FONT></SPAN></DIV>
<DIV>&nbsp;</DIV>
<DIV><SPAN class=779085103-02062010><FONT face=Arial size=2>&nbsp;$newLayer = 
new 
MgLayer($sessResId,$resourceService);<BR>&nbsp;$newLayer-&gt;SetName($layerName);<BR>&nbsp;$newLayer-&gt;SetVisible(true);<BR>&nbsp;$newLayer-&gt;SetLegendLabel($layerName);<BR>&nbsp;$newLayer-&gt;SetDisplayInLegend(false);</FONT></SPAN></DIV>
<DIV>&nbsp;</DIV>
<DIV><SPAN class=779085103-02062010><FONT face=Arial 
size=2>&nbsp;$layerCollection = $map-&gt;GetLayers();<BR>&nbsp;$layerCount = 
$layerCollection-&gt;GetCount();<BR>&nbsp;$modelLayerIndex = 
$layerCount-2;<BR>&nbsp;if 
($layerCollection-&gt;Contains("HV_isol_dev_parent"))<BR>&nbsp;{<BR>&nbsp;&nbsp;&nbsp; 
$selLayerIndex = 
$layerCollection-&gt;IndexOf("HV_isol_dev_parent");<BR>&nbsp;&nbsp;&nbsp; 
$modelLayerIndex = $selLayerIndex;<BR>&nbsp;&nbsp;&nbsp; 
$layerCollection-&gt;RemoveAt($selLayerIndex);<BR>&nbsp;}<BR>&nbsp;// Add Model 
layer to collection<BR>&nbsp;if (! 
$layerCollection-&gt;Contains($layerName))<BR>&nbsp; 
{<BR>&nbsp;&nbsp;$layerCollection-&gt;Insert($modelLayerIndex,$newLayer);<BR>&nbsp;&nbsp;// 
$layerCollection-&gt;Insert($layerCount-2,$newLayer);<BR>&nbsp; 
}</FONT></SPAN></DIV>
<DIV><SPAN class=779085103-02062010><FONT face=Arial 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=779085103-02062010><FONT face=Arial 
size=2></FONT></SPAN>&nbsp;</DIV><p> <br />*************************************************************************<br />This e-mail (including any attachments) may contain confidential or<br />privileged information and is intended for the sole use of the person(s) to<br />whom it is addressed. If you are not the intended recipient, or the person<br />responsible for delivering this message to the intended recipient, please<br />notify the sender of the message or send an e-mail to<br /><a href="mailto:help.desk@ergon.com.au">mailto:help.desk@ergon.com.au</a> immediately, and delete all copies. Any<br />unauthorised review, use, alteration, disclosure or distribution of this<br />e-mail by an unintended recipient is prohibited. Ergon Energy accepts no<br />responsibility for the content of any e-mail sent by an employee which is of<br />a personal nature.</p><p>Ergon Energy Corporation Limited      ABN 50 087 646 062<br />*************************************************************************</p>
</BODY></HTML>