[mapguide-users] Trouble Adding Existing Layers Programmatically

Jamo adam.jamison at portbris.com.au
Sun May 24 21:46:38 EDT 2009


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);

-- 
View this message in context: http://n2.nabble.com/Trouble-Adding-Existing-Layers-Programmatically-tp1807961p2967563.html
Sent from the MapGuide Users mailing list archive at Nabble.com.



More information about the mapguide-users mailing list