<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;
        font-family:Arial;
        color:navy;}
span.EmailStyle19
        {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'>Trevor,<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> </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 the response. I think I’m
doing everything you suggested correctly, but have provided the snippets
below. When the page loads the ConnectToMapGuide() method gets called,
which opens up the MgMap and sets it to a module level variable (map).
Then, Button1 is clicked which successfully adds two layers to the map. When
Button2 gets invoked, I try to remove the layers but the layers still persist
in the map. <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> </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’m not sure where to go from
here. Do you need to copy the layers in session, then add them from there
in order to have the ability to remove them? Just reaching…<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> </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> </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>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><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> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=green face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:green'>‘class vars<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=blue
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:blue'>Private</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> resourceService <font
color=blue><span style='color:blue'>As</span></font> MgResourceService<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=blue face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:blue'>Private</span></font><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>
map <font color=blue><span style='color:blue'>As</span></font> MgMap<font
color=green><span style='color:green'><o:p></o:p></span></font></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> </o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=blue
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:blue'>Private</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> <font color=blue><span
style='color:blue'>Sub</span></font> ConnectToMapGuide()<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>
<font color=green><span style='color:green'>'Connect to MapGuide site<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>
<font color=blue><span style='color:blue'>Dim</span></font> userInfo <font
color=blue><span style='color:blue'>As</span></font> <font color=blue><span
style='color:blue'>New</span></font> MgUserInformation(Session.Item(<font
color=maroon><span style='color:maroon'>"mgSessionId"</span></font>))<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>
<font color=blue><span style='color:blue'>Dim</span></font> siteConn <font
color=blue><span style='color:blue'>As</span></font> <font color=blue><span
style='color:blue'>New</span></font> MgSiteConnection<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>
siteConn.Open(userInfo)<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>
<font color=green><span style='color:green'>'set resource service<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>
resourceService = siteConn.CreateService(MgServiceType.ResourceService)<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>
<font color=green><span style='color:green'>'Open map<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>
map = <font color=blue><span style='color:blue'>New</span></font> MgMap<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>
map.Open(resourceService, Session.Item(<font color=maroon><span
style='color:maroon'>"mgMapName"</span></font>))<o:p></o:p></span></font></p>
<p class=MsoNormal><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 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>
<font color=blue><span style='color:blue'>Sub<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal><font size=2 color=blue face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:blue'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=blue
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:blue'>Protected</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> <font color=blue><span
style='color:blue'>Sub</span></font> Button1_Click(<font color=blue><span
style='color:blue'>ByVal</span></font> sender <font color=blue><span
style='color:blue'>As</span></font> <font color=blue><span style='color:blue'>Object</span></font>,
<font color=blue><span style='color:blue'>ByVal</span></font> e <font
color=blue><span style='color:blue'>As</span></font> System.EventArgs) <font
color=blue><span style='color:blue'>Handles</span></font> Button1.Click<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>
<font color=green><span style='color:green'>‘add dwf layer</span></font><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-indent:.5in;text-autospace:none'><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"'> schematicId <font
color=blue><span style='color:blue'>As</span></font> <font color=blue><span
style='color:blue'>New</span></font>MgResourceIdentifier _ <o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in;text-indent:.5in;text-autospace:
none'><font size=2 face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New"'>(<font color=maroon><span style='color:maroon'>"Library://VST/Layers/SouthOmahaTeamSchematic.LayerDefinition"</span></font>)<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>
<font color=blue><span style='color:blue'>Dim</span></font> schematic <font
color=blue><span style='color:blue'>As</span></font> MgLayer =
CreateLayer(schematicId, <font color=blue><span style='color:blue'>False</span></font>)<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>
map.GetLayers.Insert(index, schematic)<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>
<font color=green><span style='color:green'>‘add sdf layer</span></font><o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in;text-autospace:none'><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"'> valveId <font color=blue><span
style='color:blue'>As</span></font> <font color=blue><span style='color:blue'>New</span></font>
MgResourceIdentifier _ <o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in;text-indent:.5in;text-autospace:
none'><font size=2 face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New"'>(<font color=maroon><span style='color:maroon'>"Library://VST/Layers/SouthOmahaValves.LayerDefinition"</span></font>)<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>
<font color=blue><span style='color:blue'>Dim</span></font> valves <font
color=blue><span style='color:blue'>As</span></font> MgLayer =
CreateLayer(valveId, <font color=blue><span style='color:blue'>True</span></font>)<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>
map.GetLayers.Insert(index, valves)<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> <o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>
map.Save(resourceService)<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>
<font color=green><span style='color:green'>'emit javascript to refresh map<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal><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 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>
<font color=blue><span style='color:blue'>Sub<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal><font size=2 color=blue face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:blue'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=blue
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:blue'>Protected</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> <font color=blue><span
style='color:blue'>Sub</span></font> Button2_Click(<font color=blue><span
style='color:blue'>ByVal</span></font> sender <font color=blue><span
style='color:blue'>As</span></font> <font color=blue><span style='color:blue'>Object</span></font>,
<font color=blue><span style='color:blue'>ByVal</span></font> e <font
color=blue><span style='color:blue'>As</span></font> System.EventArgs) <font
color=blue><span style='color:blue'>Handles</span></font> Button2.Click<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>
<font color=blue><span style='color:blue'>Dim</span></font> lyr0 <font
color=blue><span style='color:blue'>As</span></font> MgLayer =
map.GetLayers.GetItem(0)<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>
<font color=blue><span style='color:blue'>Dim</span></font> lyr1 <font
color=blue><span style='color:blue'>As</span></font> MgLayer =
map.GetLayers.GetItem(1)<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>
map.GetLayers.Remove(lyr0)<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>
map.GetLayers.Remove(lyr1)<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>
map.Save(resourceService)<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>
<font color=green><span style='color:green'>'emit javascript to refresh map<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal><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 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>
<font color=blue><span style='color:blue'>Sub<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal><font size=2 color=blue face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:blue'><o:p> </o:p></span></font></p>
<div>
<div class=MsoNormal align=center style='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'> Trevor
Wekel [mailto:trevor.wekel@autodesk.com] <br>
<b><span style='font-weight:bold'>Sent:</span></b> Friday, January 12, 2007
3:37 PM<br>
<b><span style='font-weight:bold'>To:</span></b> Buscher, Shane;
Mapguide_users@lists.osgeo.org<br>
<b><span style='font-weight:bold'>Subject:</span></b> RE: [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> </o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 color=blue face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:blue'>Hi Shane,</span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'> <o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 color=blue face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:blue'>This should work.
During your setup, are you calling MgMap.Open() or MgMap.Create()? The
MgMap.Open() should set up the resource identifier correctly so that Save()
will have the map to the correct session repository.</span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'> <o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 color=blue face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:blue'>Is the session id being
propagated correctly? If you can do the following and the layer appears
in the viewer then the session should be ok.</span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'> <o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 color=blue face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:blue'>MgMap.Open()</span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 color=blue face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:blue'>MgMap.GetLayers().Insert(layer)</span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 color=blue face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:blue'>MgMap.Save()</span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'> <o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 color=blue face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:blue'>If the Insert() works and
Remove() doesn't</span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'> <o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 color=blue face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:blue'>MgMap.Open()<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 color=blue face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:blue'>MgMap.GetLayers().Remove(layer)<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 color=blue face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:blue'>MgMap.Save()<o:p></o:p></span></font></p>
<div>
<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'> <o:p></o:p></span></font></p>
</div>
<div>
<p class=MsoNormal style='margin-left:.5in'><font size=2 color=blue face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:blue'>Then this is probably a
bug. Also, does the behaviour depend on the number remaining layers?</span></font><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'> <o:p></o:p></span></font></p>
</div>
<div>
<p class=MsoNormal style='margin-left:.5in'><font size=2 color=blue face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:blue'>Thanks,</span></font><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal style='margin-left:.5in'><font size=2 color=blue face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:blue'>Trevor</span></font><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'> <o:p></o:p></span></font></p>
</div>
<div>
<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'> <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='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;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'> Buscher,
Shane [mailto:Shane.Buscher@nngco.com] <br>
<b><span style='font-weight:bold'>Sent:</span></b> Friday, January 12, 2007
7:16 AM<br>
<b><span style='font-weight:bold'>To:</span></b> Buscher, Shane;
Mapguide_users@lists.osgeo.org<br>
<b><span style='font-weight:bold'>Subject:</span></b> RE: [Mapguide_users] FW:
Remove layers at runtime</span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'>I haven’t got any
feedback yet, but I have been trying desperately to make this work. To
recap, I’m finding that adding a layer to a map at runtime with
MgLayerCollection.Add works fine. 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>. I am
saving the map and refreshing the map after removal. <o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in'><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? 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='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in'><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 style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in'><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’t apply for removing a layer. I can’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. Or is this a bug?<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'>Thanks for any help in
advance. <o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in'><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 style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in'><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 style='margin-left:.5in'>
<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>
</div>
<p class=MsoNormal style='margin-left:1.0in'><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:1.0in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'><o:p> </o:p></span></font></p>
<p style='margin-left:1.0in'><font size=2 face=Arial><span style='font-size:
10.0pt;font-family:Arial'>I’ve run into issues with removing all layers
from the map at runtime. See the code snippet below. All the layers
get removed from the layerCollection, but the layers still display.
I’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. I
don’t know why the same code wouldn’t work for clearing layers.
</span></font><o:p></o:p></p>
<p style='margin-left:1.0in'><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. Do I need to copy each layer in indvidual session repositories
to add and reomove them? If I don’t, will one user adding/removing
layers affect other user sessions? I know this is the case when you edit
data, but these layers are view only. </span></font> <o:p></o:p></p>
<p style='margin-left:1.0in'><font size=2 face=Arial><span style='font-size:
10.0pt;font-family:Arial'>‘</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:1.0in'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>ConnectToMapGuide() </span></font><o:p></o:p></p>
<p style='margin-left:1.0in'><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:1.0in'><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:1.0in'><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 > 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:1.0in'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>
layerCollection.Clear()</span></font><o:p></o:p></p>
<p style='margin-left:1.0in'><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:1.0in'><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:1.0in'><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:1.0in'><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'>"ForceRefresh"</span></font><o:p></o:p></p>
<p style='margin-left:1.0in'><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:1.0in'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> </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'>"refreshMap("</span></font><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>
& MapAction.RefreshMap &</span></font> <font size=2 color=maroon
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:maroon'>");"</span></font><o:p></o:p></p>
<p style='margin-left:1.0in'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>
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:1.0in'><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:1.0in'><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:1.0in'><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:1.0in'><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:1.0in'><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:1.0in'><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:1.0in'><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. </span></font></i><o:p></o:p></p>
<p style='margin-left:1.0in'><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>