<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML xmlns="http://www.w3.org/TR/REC-html40" xmlns:v =
"urn:schemas-microsoft-com:vml" xmlns:o =
"urn:schemas-microsoft-com:office:office" xmlns:w =
"urn:schemas-microsoft-com:office:word"><HEAD><TITLE>FW: Remove layers at runtime</TITLE>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.3020" name=GENERATOR><!--[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]-->
<STYLE>@font-face {
        font-family: Tahoma;
}
@font-face {
        font-family: StoneSans;
}
@page Section1 {size: 8.5in 11.0in; margin: 1.0in 1.25in 1.0in 1.25in; }
P.MsoNormal {
        FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman"
}
LI.MsoNormal {
        FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman"
}
DIV.MsoNormal {
        FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman"
}
A:link {
        COLOR: blue; TEXT-DECORATION: underline
}
SPAN.MsoHyperlink {
        COLOR: blue; TEXT-DECORATION: underline
}
A:visited {
        COLOR: purple; TEXT-DECORATION: underline
}
SPAN.MsoHyperlinkFollowed {
        COLOR: purple; TEXT-DECORATION: underline
}
P {
        FONT-SIZE: 12pt; MARGIN-LEFT: 0in; MARGIN-RIGHT: 0in; FONT-FAMILY: "Times New Roman"; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto
}
SPAN.EmailStyle18 {
        COLOR: navy; FONT-FAMILY: Arial; mso-style-type: personal-reply
}
DIV.Section1 {
        page: Section1
}
</STYLE>
</HEAD>
<BODY lang=EN-US vLink=purple link=blue>
<DIV dir=ltr align=left><SPAN class=775363021-12012007><FONT face=Arial
color=#0000ff size=2>Hi Shane,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=775363021-12012007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=775363021-12012007><FONT face=Arial
color=#0000ff size=2>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.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=775363021-12012007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=775363021-12012007><FONT face=Arial
color=#0000ff size=2>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.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=775363021-12012007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=775363021-12012007><FONT face=Arial
color=#0000ff size=2>MgMap.Open()</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=775363021-12012007><FONT face=Arial
color=#0000ff size=2>MgMap.GetLayers().Insert(layer)</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=775363021-12012007><FONT face=Arial
color=#0000ff size=2>MgMap.Save()</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=775363021-12012007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=775363021-12012007><FONT face=Arial
color=#0000ff size=2>If the Insert() works and Remove()
doesn't</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=775363021-12012007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=775363021-12012007><FONT face=Arial
color=#0000ff size=2>
<DIV dir=ltr align=left><SPAN class=775363021-12012007><FONT face=Arial
color=#0000ff size=2>MgMap.Open()</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=775363021-12012007><FONT face=Arial
color=#0000ff size=2>MgMap.GetLayers().Remove(layer)</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=775363021-12012007><FONT face=Arial
color=#0000ff size=2>MgMap.Save()</FONT></SPAN></DIV></FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=775363021-12012007></SPAN><FONT face=Arial><FONT
color=#0000ff><FONT size=2>T<SPAN class=775363021-12012007>hen this is probably
a bug. Also, does the behaviour depend on the number remaining
layers?</SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN
class=775363021-12012007></SPAN></FONT></FONT></FONT> </DIV>
<DIV><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN
class=775363021-12012007>Thanks,</SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN
class=775363021-12012007>Trevor</SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN
class=775363021-12012007></SPAN></FONT></FONT></FONT> </DIV>
<DIV><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN
class=775363021-12012007></SPAN></FONT></FONT></FONT> </DIV>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> Buscher, Shane
[mailto:Shane.Buscher@nngco.com] <BR><B>Sent:</B> Friday, January 12, 2007 7:16
AM<BR><B>To:</B> Buscher, Shane;
Mapguide_users@lists.osgeo.org<BR><B>Subject:</B> RE: [Mapguide_users] FW:
Remove layers at runtime<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV class=Section1>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">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><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">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><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><I><FONT face=StoneSans size=1><SPAN
style="FONT-SIZE: 9pt; FONT-STYLE: italic; FONT-FAMILY: StoneSans">In the
MapGuide API, getting a collection returns a reference to the collection. So
adding the layer to the layer collection immediately updates the
map.<o:p></o:p></SPAN></FONT></I></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">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><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">Thanks for any help in
advance. <o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">Regards,<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">Shane<o:p></o:p></SPAN></FONT></P>
<DIV>
<DIV class=MsoNormal style="MARGIN-LEFT: 0.5in; TEXT-ALIGN: center"
align=center><FONT face="Times New Roman" size=3><SPAN style="FONT-SIZE: 12pt">
<HR tabIndex=-1 align=center width="100%" SIZE=2>
</SPAN></FONT></DIV>
<P class=MsoNormal style="MARGIN-LEFT: 0.5in"><B><FONT face=Tahoma size=2><SPAN
style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; FONT-FAMILY: Tahoma">From:</SPAN></FONT></B><FONT
face=Tahoma size=2><SPAN style="FONT-SIZE: 10pt; 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: 0.5in"><FONT face="Times New Roman"
size=3><SPAN style="FONT-SIZE: 12pt"><o:p> </o:p></SPAN></FONT></P>
<P style="MARGIN-LEFT: 0.5in"><FONT face=Arial size=2><SPAN
style="FONT-SIZE: 10pt; 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 face="Courier New" size=2><SPAN
style="FONT-SIZE: 10pt; 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: 0.5in"><FONT face="Courier New" size=2><SPAN
style="FONT-SIZE: 10pt; 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: 0.5in"><FONT face=Arial size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">‘</SPAN></FONT><FONT
face="Courier New" color=green size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: 'Courier New'">Connect to
site server, set resource service, and open map</SPAN></FONT><o:p></o:p></P>
<P style="MARGIN-LEFT: 0.5in"><FONT face="Courier New" size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">ConnectToMapGuide()
</SPAN></FONT><o:p></o:p></P>
<P style="MARGIN-LEFT: 0.5in"><FONT face="Courier New" color=green size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: 'Courier New'">'Clear all
layers in the map</SPAN></FONT><o:p></o:p></P>
<P style="MARGIN-LEFT: 0.5in"><FONT face="Courier New" color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">Dim</SPAN></FONT><FONT
face="Courier New" size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">
layerCollection</SPAN></FONT> <FONT face="Courier New" color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">As</SPAN></FONT><FONT
face="Courier New" size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> MgLayerCollection =
map.GetLayers()</SPAN></FONT><o:p></o:p></P>
<P style="MARGIN-LEFT: 0.5in"><FONT face="Courier New" color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">If</SPAN></FONT><FONT
face="Courier New" size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> layerCollection.GetCount
> 0</SPAN></FONT> <FONT face="Courier New" color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">Then</SPAN></FONT><o:p></o:p></P>
<P style="MARGIN-LEFT: 0.5in"><FONT face="Courier New" size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">
layerCollection.Clear()</SPAN></FONT><o:p></o:p></P>
<P style="MARGIN-LEFT: 0.5in"><FONT face="Courier New" color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">End</SPAN></FONT>
<FONT face="Courier New" color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">If</SPAN></FONT><o:p></o:p></P>
<P style="MARGIN-LEFT: 0.5in"><FONT face="Courier New" size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">map.Save(resourceService)</SPAN></FONT><o:p></o:p></P>
<P style="MARGIN-LEFT: 0.5in"><FONT face="Courier New" color=green size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: 'Courier New'">'emit
javascript to refresh map</SPAN></FONT><o:p></o:p></P>
<P style="MARGIN-LEFT: 0.5in"><FONT face="Courier New" color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">Dim</SPAN></FONT><FONT
face="Courier New" size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> scriptKey</SPAN></FONT>
<FONT face="Courier New" color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">As</SPAN></FONT>
<FONT face="Courier New" color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">String</SPAN></FONT><FONT
face="Courier New" size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> =</SPAN></FONT> <FONT
face="Courier New" color=maroon size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: 'Courier New'">"ForceRefresh"</SPAN></FONT><o:p></o:p></P>
<P style="MARGIN-LEFT: 0.5in"><FONT face="Courier New" color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">If</SPAN></FONT>
<FONT face="Courier New" color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">Not</SPAN></FONT><FONT
face="Courier New" size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">
Page.ClientScript.IsStartupScriptRegistered(<FONT color=blue><SPAN
style="COLOR: blue">Me</SPAN></FONT>.GetType, scriptKey)</SPAN></FONT> <FONT
face="Courier New" color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">Then</SPAN></FONT><o:p></o:p></P>
<P style="MARGIN-LEFT: 0.5in"><FONT face="Courier New" size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> </SPAN></FONT> <FONT
face="Courier New" color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">Dim</SPAN></FONT><FONT
face="Courier New" size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> javaScript</SPAN></FONT>
<FONT face="Courier New" color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">As</SPAN></FONT>
<FONT face="Courier New" color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">String</SPAN></FONT><FONT
face="Courier New" size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> =</SPAN></FONT> <FONT
face="Courier New" color=maroon size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: 'Courier New'">"refreshMap("</SPAN></FONT><FONT
face="Courier New" size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> & MapAction.RefreshMap
&</SPAN></FONT> <FONT face="Courier New" color=maroon size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: 'Courier New'">");"</SPAN></FONT><o:p></o:p></P>
<P style="MARGIN-LEFT: 0.5in"><FONT face="Courier New" size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">
Page.ClientScript.RegisterStartupScript(<FONT color=blue><SPAN
style="COLOR: blue">Me</SPAN></FONT>.GetType, scriptKey,
javaScript,</SPAN></FONT> <FONT face="Courier New" color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">True</SPAN></FONT><FONT
face="Courier New" size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">)</SPAN></FONT><o:p></o:p></P>
<P style="MARGIN-LEFT: 0.5in"><FONT face="Courier New" color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">End</SPAN></FONT>
<FONT face="Courier New" color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">If</SPAN></FONT><o:p></o:p></P>
<P style="MARGIN-LEFT: 0.5in"><A name=""><FONT face=Arial size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Regards,</SPAN></FONT></A><o:p></o:p></P>
<P style="MARGIN-LEFT: 0.5in"><FONT face=Arial size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Shane</SPAN></FONT><o:p></o:p></P>
<P style="MARGIN-LEFT: 0.5in"><FONT face=Arial color=gray size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: gray; FONT-FAMILY: Arial">Operations
IT</SPAN></FONT><o:p></o:p></P>
<P style="MARGIN-LEFT: 0.5in"><FONT face=Arial color=gray size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: gray; FONT-FAMILY: Arial">Northern Natural
Gas</SPAN></FONT><o:p></o:p></P>
<P style="MARGIN-LEFT: 0.5in"><FONT face=Arial color=gray size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: gray; FONT-FAMILY: Arial">402.398.7841</SPAN></FONT><o:p></o:p></P>
<P style="MARGIN-LEFT: 0.5in"><I><FONT face=Arial color=gray size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: gray; FONT-STYLE: italic; FONT-FAMILY: Arial">We
think in generalities, but live in detail.
</SPAN></FONT></I><o:p></o:p></P>
<P style="MARGIN-LEFT: 0.5in"><I><FONT face=Arial color=gray size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: gray; FONT-STYLE: italic; FONT-FAMILY: Arial">-Alred
North Whitehead</SPAN></FONT></I><o:p></o:p></P></DIV></BODY></HTML>