[mapguide-users] Add new layer to map

Mark Pendergraft markp at Meadgilman.com
Wed Jan 21 10:44:59 EST 2009


Are you trying to add permanent layers to the map?

Does this need to happen at runtime?

-Mark

 

From: mapguide-users-bounces at lists.osgeo.org
[mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of Kenneth
Skovhede, GEOGRAF A/S
Sent: Wednesday, January 21, 2009 2:24 AM
To: MapGuide Users Mail List
Subject: Re: [mapguide-users] Add new layer to map

 

I don't understand what you mean.
Changes to the runtime map does not go into MGStudio.
Only changes to the MapDefinition xml can be seen there.



Regards, Kenneth Skovhede, GEOGRAF A/S



sekko970 skrev: 

Dear Kenneth,
I need your help for a second problem:
 
I apparently save successfully the new layer into library repository
(the
legend and the map are correctly updated, and from MGStudio the new
layer is
visible in layers list), but in MGStudio 'Layer by group' view, my layer
doesn't appear, so that when I reload the map, the new layer is lost
(but
it's present in MGStudio).
 
Have you some idea?
Thanks, Fabio
 
 
 
 
sekko970 wrote:
  

	You are right!
	 
	Many thanks.
	 
	Fabio
	 
	 
	 
	 
	sekko970 wrote:
	    

		Dear all,
		I need to add a layer to my map from XML definition.
		 
		This is my code:
		 
		    Public Sub CreateLater(ByVal sessionID As String,
ByVal mapName As
		String, _
		                                   ByVal newLayerName As
String, ByVal
		groupName As String)
		 
		        Dim userInfo As New MgUserInformation
		        userInfo.SetMgSessionId(sessionID)
		 
		        Dim siteConn As New MgSiteConnection
		        siteConn.Open(userInfo)
		 
		        Dim resourceSrvc As MgResourceService =
		siteConn.CreateService(MgServiceType.ResourceService)
		        Dim map As New MgMap()
		        map.Open(resourceSrvc, mapName)
		 
		        'Loading XML layer
		        Dim newLayerXML As New XmlDocument
		        newLayerXML.Load(Me.MapPath("NewLayer.xml"))
		 
		        'Saving new layer in session repository
		        Dim byteSource As New
	
MgByteSource(Encoding.UTF8.GetBytes(newLayerXML.OuterXml),
		newLayerXML.OuterXml.Length)
		        byteSource.SetMimeType(MgMimeType.Xml)
		        Dim resID As New MgResourceIdentifier("Session:"
& sessionID &
		"//" & newLayerName & "." &
MgResourceType.LayerDefinition)
		        resourceSrvc.SetResource(resID,
byteSource.GetReader(), Nothing)
		        Dim newLayer As New MgLayerBase(resID,
resourceSrvc)
		 
		        'Add new layer to group
		        Dim layerGroup As MgLayerGroup = Nothing
		        If map.GetLayerGroups().Contains(groupName) Then
		            layerGroup =
map.GetLayerGroups.GetItem(groupName)
		        Else
		            layerGroup = New MgLayerGroup(groupName)
		            layerGroup.SetVisible(True)
		            layerGroup.SetDisplayInLegend(True)
		            layerGroup.SetLegendLabel(groupName)
		            map.GetLayerGroups.Add(layerGroup)
		        End If
		        newLayer.SetGroup(layerGroup)
		 
		        'Insert new layer to map
		        newLayer.SetName(newLayerName)
		        newLayer.SetVisible(True)
		        newLayer.SetLegendLabel(newLayerName)
		        newLayer.SetDisplayInLegend(True)
		        map.GetLayers.Insert(0, newLayer)
		 
		        map.Save(resourceSrvc)
		 
		Saving the map, an MgNotImplementedException occurs.
		 
		Where is my mistake?
		 
		Thanks in advance for your help.
		Fabio
		 
		 
		      

	 
	    

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


More information about the mapguide-users mailing list