[mapguide-users] Trouble Adding Existing Layers Programmatically

Kori Maleski Kori.Maleski at websoftdev.com
Wed Dec 20 14:04:04 EST 2006


You're not saving the map back to the Session.

 

Try something like this after you have added the layercollection:

 

 

 

 

                'Create Identifier for the Session Map

                Dim l_oSessionResourceIdentifier As New
MgResourceIdentifier("Session:" & Session & "//" & MapName & ".Map")

                'Save the Session Map

                l_oMap.Save(l_oResourceSrvc, l_oSessionResourceIdentifier)

 

 

 

Kori 

 

 

Kori Maleski

Senior Application Developer

WEBSOFT DEVELOPERS, INC.

P: (530) 759-8754 ext 114

F: (530) 759-0923

kori.maleski at websoftdev.com

________________________________

 

  _____  

From: Buscher, Shane [mailto:Shane.Buscher at nngco.com] 
Sent: December 20, 2006 8:37 AM
To: users at mapguide.osgeo.org
Subject: RE: [mapguide-users] Trouble Adding Existing Layers
Programmatically 

 

I am overlooking saving the map back to the session repository, which sounds
like my problem.  I'll look into this.  Here's the code if you have any
other suggestions:

 

Dim webConfig As String = Request.ServerVariables("APPL_PHYSICAL_PATH") &
"webconfig.ini"

MapGuideApi.MgInitializeWebTier(webConfig)

GetRequestParameters() 'gets mapName and sessionID

 

Dim userInfo As New MgUserInformation(sessionId)

Dim siteConn As New MgSiteConnection

siteConn.Open(userInfo)

 

Dim resourceService As MgResourceService =
siteConn.CreateService(MgServiceType.ResourceService)

map.Open(resourceService, mapName)

 

Dim resId As New
MgResourceIdentifier("Library://VST_Prototype/Layers/SouthOmahaValves.LayerD
efinition")

Dim layerCollection As MgLayerCollection = map.GetLayers()

 

Dim lyr As New MgLayer(resId, resourceService)

layerCollection.Add(lyr)

 

lyr.SetVisible(True)

lyr.SetDisplayInLegend(True)

lyr.ForceRefresh()

 

  _____  

From: Jason Birch [mailto:Jason.Birch at nanaimo.ca] 
Sent: Wednesday, December 20, 2006 9:18 AM
To: users at mapguide.osgeo.org
Subject: RE: [mapguide-users] Trouble Adding Existing Layers
Programmatically 

 

Code might help with diagnosis.

 

You're saving the map back to the session repository after adding the layer,
right?

 

Jason

 

 

  _____  

From: Buscher, Shane
Sent: Wed 2006-12-20 5:48 AM
To: users at mapguide.osgeo.org
Subject: [mapguide-users] Trouble Adding Existing Layers Programmatically 

I have some layers that exist in my repository, but aren't added to the
published map with Studio.   Instead, I want end users to be able to add and
remove these layers from the repository at runtime.  I'm using the
MgLayerCollection.Add method to display layers, but they don't show up in
the map.  According to the developers guide, firing this method should
automatically add a layer to the map (p. 48).  The layers I'm trying to add
do get added to the collection, but don't display even after performing a
MgLayer.Visible=True and MgLayer.ForceRefresh.  I am also calling the Viewer
API to refresh: parent.mapFrame.Refresh(). 

Anyone have any suggestions or sample code?  

Regards,

Shane

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide-users/attachments/20061220/591b2f77/attachment.html


More information about the Mapguide-users mailing list