<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<title>FW: Remove layers at runtime</title>
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:StoneSans;
        panose-1:0 0 0 0 0 0 0 0 0 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
p
        {mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman";}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:Arial;
        color:navy;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
-->
</style>

</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>I haven&#8217;t got any feedback yet, but I
have been trying desperately to make this work.&nbsp; To recap, I&#8217;m
finding that adding a layer to a map at runtime with MgLayerCollection.Add
works fine.&nbsp; However, when I try to remove layer(s) with
MgLayerCollection.Clear, MgLayerCollection.Remove, or
MgLayerCollection.RemoveAt the layer(s) are indeed removed from the collection-
but <i><span style='font-style:italic'>not the map</span></i>.&nbsp; I am
saving the map and refreshing the map after removal.&nbsp; <o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 color=navy
face=Arial><span style='font-size:10.0pt;font-family:Arial;color:navy'>So why
does inserting a layer into the MgMapCollection work, but removing not?&nbsp; Looking
at the developers guide on page 56 there is a note for getting a layer
collection from the map (MgMap.GetLayers): <o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 color=navy
face=Arial><span style='font-size:10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><i><font size=1 face=StoneSans><span
style='font-size:9.0pt;font-family:StoneSans;font-style:italic'>In the MapGuide
API, getting a collection returns a reference to the collection. So adding the
layer to the layer collection immediately updates the map.<o:p></o:p></span></font></i></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>I am get the impression that adding a
layer to the collection automatically updates the map, this doesn&#8217;t apply
for removing a layer.&nbsp; I can&#8217;t figure out what I need to do to mimic
what the api does for you when inserting a layer when trying to remove a
layer.&nbsp; Or is this a bug?<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Thanks for any help in advance.&nbsp; <o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Regards,<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Shane<o:p></o:p></span></font></p>

<div>

<div class=MsoNormal align=center style='margin-left:.5in;text-align:center'><font
size=3 face="Times New Roman"><span style='font-size:12.0pt'>

<hr size=2 width="100%" align=center tabindex=-1>

</span></font></div>

<p class=MsoNormal style='margin-left:.5in'><b><font size=2 face=Tahoma><span
style='font-size:10.0pt;font-family:Tahoma;font-weight:bold'>From:</span></font></b><font
size=2 face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'> mapguide_users-bounces@lists.osgeo.org
[mailto:mapguide_users-bounces@lists.osgeo.org] <b><span style='font-weight:
bold'>On Behalf Of </span></b>Buscher, Shane<br>
<b><span style='font-weight:bold'>Sent:</span></b> Tuesday, January 09, 2007
4:49 PM<br>
<b><span style='font-weight:bold'>To:</span></b> Mapguide_users@lists.osgeo.org<br>
<b><span style='font-weight:bold'>Subject:</span></b> [Mapguide_users] FW:
Remove layers at runtime</span></font><o:p></o:p></p>

</div>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p style='margin-left:.5in'><font size=2 face=Arial><span style='font-size:
10.0pt;font-family:Arial'>I&#8217;ve run into issues with removing all layers
from the map at runtime.&nbsp; See the code snippet below.&nbsp; All the layers
get removed from the layerCollection, but the layers still display.&nbsp;
I&#8217;ve successfully used the same code to insert layers, except I execute
the</span></font> <font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>layerCollection.Insert(index, layer) method.&nbsp; I
don&#8217;t know why the same code wouldn&#8217;t work for clearing
layers.&nbsp; </span></font><o:p></o:p></p>

<p style='margin-left:.5in'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>I have multiple layers
stored in a library repository that users need to add and remove at
runtime.&nbsp; Do I need to copy each layer in indvidual session repositories
to add and reomove them?&nbsp; If I don&#8217;t, will one user adding/removing
layers affect other user sessions?&nbsp; I know this is the case when you edit
data, but these layers are view only.&nbsp;&nbsp;</span></font> <o:p></o:p></p>

<p style='margin-left:.5in'><font size=2 face=Arial><span style='font-size:
10.0pt;font-family:Arial'>&#8216;</span></font><font size=2 color=green
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:green'>Connect to site server, set resource service, and open map</span></font><o:p></o:p></p>

<p style='margin-left:.5in'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>ConnectToMapGuide()&nbsp; </span></font><o:p></o:p></p>

<p style='margin-left:.5in'><font size=2 color=green face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:green'>'Clear all
layers in the map</span></font><o:p></o:p></p>

<p style='margin-left:.5in'><font size=2 color=blue face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:blue'>Dim</span></font><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>
layerCollection</span></font> <font size=2 color=blue face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:blue'>As</span></font><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>
MgLayerCollection = map.GetLayers()</span></font><o:p></o:p></p>

<p style='margin-left:.5in'><font size=2 color=blue face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:blue'>If</span></font><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>
layerCollection.GetCount &gt; 0</span></font> <font size=2 color=blue
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:blue'>Then</span></font><o:p></o:p></p>

<p style='margin-left:.5in'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;
layerCollection.Clear()</span></font><o:p></o:p></p>

<p style='margin-left:.5in'><font size=2 color=blue face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:blue'>End</span></font>
<font size=2 color=blue face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New";color:blue'>If</span></font><o:p></o:p></p>

<p style='margin-left:.5in'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>map.Save(resourceService)</span></font><o:p></o:p></p>

<p style='margin-left:.5in'><font size=2 color=green face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:green'>'emit javascript
to refresh map</span></font><o:p></o:p></p>

<p style='margin-left:.5in'><font size=2 color=blue face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:blue'>Dim</span></font><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>
scriptKey</span></font> <font size=2 color=blue face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:blue'>As</span></font> <font
size=2 color=blue face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:blue'>String</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> =</span></font> <font
size=2 color=maroon face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New";color:maroon'>&quot;ForceRefresh&quot;</span></font><o:p></o:p></p>

<p style='margin-left:.5in'><font size=2 color=blue face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:blue'>If</span></font> <font
size=2 color=blue face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:blue'>Not</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>
Page.ClientScript.IsStartupScriptRegistered(<font color=blue><span
style='color:blue'>Me</span></font>.GetType, scriptKey)</span></font> <font
size=2 color=blue face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:blue'>Then</span></font><o:p></o:p></p>

<p style='margin-left:.5in'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;</span></font> <font
size=2 color=blue face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:blue'>Dim</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> javaScript</span></font> <font
size=2 color=blue face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:blue'>As</span></font> <font size=2 color=blue
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:blue'>String</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> =</span></font> <font
size=2 color=maroon face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New";color:maroon'>&quot;refreshMap(&quot;</span></font><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>
&amp; MapAction.RefreshMap &amp;</span></font> <font size=2 color=maroon
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:maroon'>&quot;);&quot;</span></font><o:p></o:p></p>

<p style='margin-left:.5in'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;
Page.ClientScript.RegisterStartupScript(<font color=blue><span
style='color:blue'>Me</span></font>.GetType, scriptKey, javaScript,</span></font>
<font size=2 color=blue face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New";color:blue'>True</span></font><font size=2
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>)</span></font><o:p></o:p></p>

<p style='margin-left:.5in'><font size=2 color=blue face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:blue'>End</span></font>
<font size=2 color=blue face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New";color:blue'>If</span></font><o:p></o:p></p>

<p style='margin-left:.5in'><a name=""><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'>Regards,</span></font></a><o:p></o:p></p>

<p style='margin-left:.5in'><font size=2 face=Arial><span style='font-size:
10.0pt;font-family:Arial'>Shane</span></font><o:p></o:p></p>

<p style='margin-left:.5in'><font size=2 color=gray face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:gray'>Operations IT</span></font><o:p></o:p></p>

<p style='margin-left:.5in'><font size=2 color=gray face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:gray'>Northern Natural Gas</span></font><o:p></o:p></p>

<p style='margin-left:.5in'><font size=2 color=gray face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:gray'>402.398.7841</span></font><o:p></o:p></p>

<p style='margin-left:.5in'><i><font size=2 color=gray face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:gray;font-style:italic'>We
think in generalities, but live in detail.&nbsp; </span></font></i><o:p></o:p></p>

<p style='margin-left:.5in'><i><font size=2 color=gray face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:gray;font-style:italic'>-Alred
North Whitehead</span></font></i><o:p></o:p></p>

</div>

</body>

</html>