<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:st1="urn:schemas-microsoft-com:office:smarttags" 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)">
<base
href="https://nngowa.nngco.com/exchange/Shane.Buscher/Drafts/RE:%20%5bMapguide_users%5d%20FW:%20Remove%20layers%20at%20runtime.EML/1_text.htm">
<!--[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>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
name="City"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
name="place"/>
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
font-face {
        font-family: Tahoma;
}
font-face {
        font-family: StoneSans;
}
font-face {
        FONT-FAMILY: Tahoma
}
font-face {
        FONT-FAMILY: StoneSans
}
/* 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
        {font-family:Arial;
        color:navy;}
span.emailstyle19
        {font-family:Arial;
        color:navy;}
span.emailstyle20
        {font-family:Arial;
        color:navy;}
span.EmailStyle21
        {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'>Walt/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'>I’m definitely refreshing by calling
the Refresh method in the viewer api. My exact code is below. I
know the refresh gets executed successfully because I see a quick status bar in
the top left corner of the viewer flash. If I comment out the javascript
call, no status bar flashes. Furthermore, the built-in RefreshMap command
that you can add as a button in Studio doesn’t work either after running
the code snippet below. <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 also know, according to the users guide
p. 56, that you don’t have to refresh the map from the client after
adding layers because the LayerCollection takes care of this for you. I’ve
tested this when adding layers, and this is true. I am somewhat assuming
that removing a layer would be the same. I wonder if there is a problem
with the DWF viewer. I suppose I can try the <st1:City w:st="on"><st1:place
w:st="on">AJAX</st1:place></st1:City> viewer… It might be really
helpful if somebody could duplicate the issue. <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 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> 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'>'Remove layers </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> 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 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> scriptKey <font
color=blue><span style='color:blue'>As</span></font> <font color=blue><span
style='color:blue'>String</span></font> = <font color=maroon><span
style='color:maroon'>"Refresh"<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'>If</span></font> <font color=blue><span
style='color:blue'>Not</span></font>
Page.ClientScript.IsStartupScriptRegistered(<font color=blue><span
style='color:blue'>Me</span></font>.GetType, scriptKey) <font color=blue><span
style='color:blue'>Then<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> javaScript <font
color=blue><span style='color:blue'>As</span></font> <font color=blue><span
style='color:blue'>String</span></font> = <font color=maroon><span
style='color:maroon'>"parent.parent.mapFrame.Refresh();"<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"'>
Page.ClientScript.RegisterStartupScript(<font color=blue><span
style='color:blue'>Me</span></font>.GetType, scriptKey, javaScript, <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"'>
<font color=blue><span style='color:blue'>End</span></font> <font color=blue><span
style='color:blue'>If<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'> <font color=blue><span
style='color:blue'>End</span></font> <font color=blue><span style='color:blue'>Sub</span></font></span></font><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>
<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>Walt Welton-Lair<br>
<b><span style='font-weight:bold'>Sent:</span></b> Monday, January 15, 2007
1:52 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> RE: [mapguide-users] 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>
<div>
<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'>Yeah a missing refresh would make sense. Isn't
it the client's responsibility though to request the refresh?<o:p></o:p></span></font></p>
</div>
<blockquote style='margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt'>
<div>
<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'><font size=2 face="Times New Roman"><span
style='font-size:10.0pt'>-----Original Message----- <br>
<b><span style='font-weight:bold'>From:</span></b>
mapguide-users-bounces@lists.osgeo.org on behalf of Trevor Wekel <br>
<b><span style='font-weight:bold'>Sent:</span></b> Mon 1/15/2007 7:12 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'>Cc:</span></b> <br>
<b><span style='font-weight:bold'>Subject:</span></b> [mapguide-users] 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=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'>Hmm... I wonder if the
viewer is not bothering to request the map overlay image again? That
would explain the behaviour you are seeing.</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'>Are you using a Windows
box as a client? Are you familiar with Fiddler?</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'>Fiddler is an HTTP proxy
that captures HTTP requests and responses. If you install and use it, you
should be able to see all the traffic between the client and Web Extensions /
MapAgent. There should be a GETDYNAMICMAPOVERLAY request generated by the
client. This request should refresh the map and show the added/removed
layers.</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>
</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'>Also, are you using Base
Map layers (ie. tiled images)? Base Map layers should not be changed on
the fly. They should be considered static. This is probably not an
issue since you are adding dynamic layers but I just figured I would check.</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>
<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 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> Monday, January 15, 2007
11:04 AM<br>
<b><span style='font-weight:bold'>To:</span></b> Trevor Wekel;
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'>Trevor,</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=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'>I think I found a big
hint after testing what you suggested. When the layers I’m trying
to remove are within the map view extent, they do not ‘disappear’
upon removing them. However, If the layers are completely outside the map
view extent they indeed get removed with the same code. It doesn’t
matter if it’s one layer or multiples. Hopefully this gives you
something to work with. </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=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'>Regards,</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=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'>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>
<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'> Trevor
Wekel [mailto:trevor.wekel@autodesk.com] <br>
<b><span style='font-weight:bold'>Sent:</span></b> Monday, January 15, 2007
11:18 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>
</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 class=MsoNormal style='margin-left:1.0in'><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:1.0in'><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:1.0in'><font size=2 color=blue
face=Arial><span style='font-size:10.0pt;font-family:Arial;color:blue'>My
bad. I've been working with the Mapguide 1.1.x and trunk branches. You
are working on the released 1.0.x branch. Sorry for the confusion.
1.0.x does not have the boolean return.</span></font><o:p></o:p></p>
<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 class=MsoNormal style='margin-left:1.0in'><font size=2 color=blue
face=Arial><span style='font-size:10.0pt;font-family:Arial;color:blue'>Is there
any difference if you try to remove only one layer so there are still
layers on the map?</span></font><o:p></o:p></p>
<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 class=MsoNormal style='margin-left:1.0in'><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>
<p class=MsoNormal style='margin-left:1.0in'><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>
<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>
<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='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;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'> Buscher,
Shane [mailto:Shane.Buscher@nngco.com] <br>
<b><span style='font-weight:bold'>Sent:</span></b> Saturday, January 13, 2007
1:31 PM<br>
<b><span style='font-weight:bold'>To:</span></b> Trevor Wekel;
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 id=idOWAReplyText61961>
<div>
<p class=MsoNormal style='margin-left:1.0in'><font size=2 color=black
face=Arial><span style='font-size:10.0pt;font-family:Arial;color:black'>Trevor,</span></font><o:p></o:p></p>
</div>
<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>
</div>
<div>
<p class=MsoNormal style='margin-left:1.0in'><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'>MgLayerCollection.Remove doesn't return
a boolean according to the api documentation, and also doesn't indicate it in
the intellisense. </span></font><o:p></o:p></p>
</div>
<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>
</div>
<div>
<p class=MsoNormal style='margin-left:1.0in'><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'>Regards,</span></font><o:p></o:p></p>
</div>
<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>
</div>
<div>
<p class=MsoNormal 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>
</div>
</div>
<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>
<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='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;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'> Trevor
Wekel [mailto:trevor.wekel@autodesk.com]<br>
<b><span style='font-weight:bold'>Sent:</span></b> Fri 1/12/2007 5:18 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>
<div>
<p class=MsoNormal style='margin-left:1.0in'><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:1.0in'><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:1.0in'><font size=2 color=blue
face=Arial><span style='font-size:10.0pt;font-family:Arial;color:blue'>Remove()
should returns a boolean true or false. false indicates that the layer
was not removed. Can you see if the remove was successful? (just trying
to debug a bit)</span></font><o:p></o:p></p>
<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 class=MsoNormal style='margin-left:1.0in'><font size=2 color=blue
face=Arial><span style='font-size:10.0pt;font-family:Arial;color:blue'>Thanks,<br>
Trevor</span></font><o:p></o:p></p>
<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>
<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='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;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'> Buscher,
Shane [mailto:Shane.Buscher@nngco.com] <br>
<b><span style='font-weight:bold'>Sent:</span></b> Friday, January 12, 2007
4:13 PM<br>
<b><span style='font-weight:bold'>To:</span></b> Trevor Wekel;
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:1.0in'><font size=2 color=navy
face=Arial><span style='font-size:10.0pt;font-family:Arial;color:navy'>Trevor,</span></font><o:p></o:p></p>
<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 class=MsoNormal style='margin-left:1.0in'><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. </span></font><o:p></o:p></p>
<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 class=MsoNormal style='margin-left:1.0in'><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…</span></font><o:p></o:p></p>
<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 class=MsoNormal style='margin-left:1.0in'><font size=2 color=navy
face=Arial><span style='font-size:10.0pt;font-family:Arial;color:navy'>Regards,</span></font><o:p></o:p></p>
<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 class=MsoNormal style='margin-left:1.0in'><font size=2 color=navy
face=Arial><span style='font-size:10.0pt;font-family:Arial;color:navy'>Shane</span></font><o:p></o:p></p>
<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 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 class=MsoNormal 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'>‘class vars</span></font><o:p></o:p></p>
<p class=MsoNormal 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'>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</span></font><o:p></o:p></p>
<p class=MsoNormal 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'>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</span></font><o:p></o:p></p>
<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 class=MsoNormal 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'>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()</span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:1.0in'><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</span></font></span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:1.0in'><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>))</span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:1.0in'><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</span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:1.0in'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>
siteConn.Open(userInfo)</span></font><o:p></o:p></p>
<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 class=MsoNormal style='margin-left:1.0in'><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</span></font></span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:1.0in'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>
resourceService = siteConn.CreateService(MgServiceType.ResourceService)</span></font><o:p></o:p></p>
<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 class=MsoNormal style='margin-left:1.0in'><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</span></font></span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:1.0in'><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</span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:1.0in'><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>))</span></font><o:p></o:p></p>
<p class=MsoNormal 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 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> <font color=blue><span
style='color:blue'>Sub</span></font></span></font><o:p></o:p></p>
<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 class=MsoNormal 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'>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</span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:1.0in'><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></span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:1.0in;text-indent:.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"'> schematicId <font
color=blue><span style='color:blue'>As</span></font> <font color=blue><span
style='color:blue'>New</span></font>MgResourceIdentifier _
</span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:1.5in;text-indent:.5in'><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>)</span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:1.0in'><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>)</span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:1.0in'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>
map.GetLayers.Insert(index, schematic)</span></font><o:p></o:p></p>
<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 class=MsoNormal style='margin-left:1.0in'><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></span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:1.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"'> valveId <font color=blue><span
style='color:blue'>As</span></font> <font color=blue><span style='color:blue'>New</span></font>
MgResourceIdentifier _ </span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:1.5in;text-indent:.5in'><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>)</span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:1.0in'><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>)</span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:1.0in'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>
map.GetLayers.Insert(index, valves)</span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:1.0in'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>
</span></font><o:p></o:p></p>
<p class=MsoNormal 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 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 class=MsoNormal style='margin-left:1.0in'><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</span></font></span></font><o:p></o:p></p>
<p class=MsoNormal 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 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> <font color=blue><span
style='color:blue'>Sub</span></font></span></font><o:p></o:p></p>
<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 class=MsoNormal 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'>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</span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:1.0in'><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)</span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:1.0in'><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)</span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:1.0in'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>
map.GetLayers.Remove(lyr0)</span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:1.0in'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>
map.GetLayers.Remove(lyr1)</span></font><o:p></o:p></p>
<p class=MsoNormal 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 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 class=MsoNormal style='margin-left:1.0in'><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</span></font></span></font><o:p></o:p></p>
<p class=MsoNormal 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 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> <font color=blue><span
style='color:blue'>Sub</span></font></span></font><o:p></o:p></p>
<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>
<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.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:1.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:1.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:1.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:1.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:1.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:1.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:1.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:1.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:1.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:1.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:1.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:1.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:1.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:1.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:1.5in'><font size=2 color=blue
face=Arial><span style='font-size:10.0pt;font-family:Arial;color:blue'>MgMap.GetLayers().Remove(layer)</span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:1.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>
<div>
<p class=MsoNormal style='margin-left:1.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:1.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:1.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:1.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:1.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:1.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:1.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'> <o:p></o:p></span></font></p>
</div>
<div style='margin-left:.5in'>
<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>
</div>
<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:1.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:1.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. </span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:1.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:1.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): </span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:1.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:1.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.</span></font></i><o:p></o:p></p>
<p class=MsoNormal style='margin-left:1.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:1.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?</span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:1.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:1.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. </span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:1.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:1.5in'><font size=2 color=navy
face=Arial><span style='font-size:10.0pt;font-family:Arial;color:navy'>Regards,</span></font><o:p></o:p></p>
<p class=MsoNormal style='margin-left:1.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:1.5in'><font size=2 color=navy
face=Arial><span style='font-size:10.0pt;font-family:Arial;color:navy'>Shane</span></font><o:p></o:p></p>
<div>
<div style='margin-left:.5in'>
<div style='margin-left:.5in'>
<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>
</div>
</div>
<p class=MsoNormal style='margin-left:2.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:2.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:2.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:2.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:2.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:2.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:2.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:2.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:2.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:2.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:2.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:2.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:2.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:2.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:2.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:2.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:2.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:2.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:2.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:2.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:2.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:2.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:2.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:2.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:2.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>
</blockquote>
</div>
</body>
</html>