[mapguide-users] Add new layer to map

sekko970 sekko970 at virgilio.it
Wed Jan 21 04:53:55 EST 2009


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

-- 
View this message in context: http://n2.nabble.com/Add-new-layer-to-map-tp2186494p2191381.html
Sent from the MapGuide Users mailing list archive at Nabble.com.



More information about the mapguide-users mailing list