[mapguide-users] Trouble Adding Existing Layers Programmatically

Buscher, Shane Shane.Buscher at nngco.com
Wed Dec 20 11:37:00 EST 2006


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.La
yerDefinition")

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/4c58034a/attachment.html


More information about the Mapguide-users mailing list