<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Also, to clear up any confusion:<br>
<br>
The MgMap object is the runtime map.<br>
The MgLayer objects are layers attached to the runtime map (runtime
layers).<br>
"new MgLayer" does not create anything (other than the object itself).<br>
You reference a LayerDefinition in an MgLayer, you do not create the
layer.<br>
<br>
You can think of the runtime map as a binary copy of the MapDefinition.<br>
The runtime layers only contain a few attributes (visible, show in
legend, etc.),<br>
and otherwise just reference the layer.<br>
<br>
If you were to modify the MapDefinition, you would have to restart the
viewer to display the changes.<br>
Also, any other user who happens to start the viewer after the update
will see the changes.<br>
Changes to the runtime map only happens for the current user, so you
can alter the runtime map as much<br>
as you like, and still allow other users to see the map as expected.<br>
<br>
You can probably decide what is the best solution in your case, but
unless you are building<br>
a new map editor, you are likely best off with the runtime map.<br>
<pre class="moz-signature" cols="72">Regards, Kenneth Skovhede, GEOGRAF A/S
</pre>
<br>
<br>
Jackie Ng skrev:
<blockquote cite="mid:1243234193934-2968251.post@n2.nabble.com"
type="cite">
<pre wrap="">The duplicate object is most likely caused by the line:
map.GetLayers().Add(listLayer)
If there is a possibility of this code path being executed more than once,
you should check for the existence of the layer (by name) before adding it
to the map.
- Jackie
Jamo wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Anyone able to tell me why this would not be working?
I'm trying to add a layer that already exists in the repositry... it
errors with duplicate object.... ? though it is not in the map as of yet.
or is it because this is attempting to create a new layer in the repositry
? MgLayer listLayer = new MgLayer(LibLayer, ResourceService); ?
I'm attempting to add the layers programatically when a user selects them,
however it could be just as good to add the layer to the map definition,
which of these would you prefer?
MapGuideApi.MgInitializeWebTier(Request.ServerVariables["APPL_PHYSICAL_PATH"]
+ "../webconfig.ini");
MgUserInformation userInfo = new MgUserInformation(sessionID);
MgSite site = new MgSite();
//connect to site
site.Open(userInfo);
MgSiteConnection siteConnection = new MgSiteConnection();
//open site connection
siteConnection.Open(userInfo);
MgResourceService ResourceService =
siteConnection.CreateService(MgServiceType.ResourceService) as
MgResourceService;
MgFeatureService FeatureService =
siteConnection.CreateService(MgServiceType.FeatureService) as
MgFeatureService;
MgMap map = new MgMap(siteConnection);
map.Open(mapName);
MgResourceIdentifier LibLayer = new
MgResourceIdentifier("Library://Markup/" + mapName + "/" +
LayersDDL.SelectedItem.Text + ".LayerDefinition");
MgLayer listLayer = new MgLayer(LibLayer, ResourceService);
map.GetLayers().Add(listLayer);
map.Save(ResourceService);
</pre>
</blockquote>
<pre wrap=""><!---->
</pre>
</blockquote>
</body>
</html>