Hi,

The following code should do what you're looking for.

        Public Shared Function GetAllResources(ByRef resSvc As
MgResourceService, ByVal resId As MgResourceIdentifier, ByVal nDepth As
Integer, ByVal szType As String) As XmlDocument
                Dim retDoc As XmlDocument
                retDoc = ConvertMgReaderXml(resSvc.EnumerateResources(resId,
nDepth, szType))
                Return XmlDocument
        End Function

Set the , resID to "Library://",  depth to -1 I believe for full recursion.
For Type use LayerDefinition

And ConvertMgReaderXML is:
        Public Shared Function ConvertMgReaderXml(ByVal byteReader As
MgByteReader) As XmlDocument
                Dim szXML As String
                Try
                        szXML = byteReader.ToString
                Catch ex As Exception
                        Throw ex
                End Try
                Dim nByteCount As Integer
                Dim arrByte(szXML.Length) As Byte
                Try
                        nByteCount = Encoding.UTF8.GetBytes(szXML, 0,
szXML.Length, arrByte, 0)
                Catch ex As Exception
                        Throw ex
                End Try

                Dim memStream As New MemoryStream(arrByte)
                Dim retDoc As New XmlDocument
                retDoc.PreserveWhitespace = True
                Try
                        retDoc.Load(memStream)
                Catch ex As Exception
                        memStream.Close()
                        memStream.Dispose()
                        Throw ex
                End Try
                memStream.Close()
                memStream.Dispose()
                Return retDoc
        End Function

Hope that helps.
darrin


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of adnan.c
Sent: Thursday, June 12, 2008 4:17 AM
To: [email protected]
Subject: Re[mapguide-users] turn all Layers from MapGuide repository


Hello All,

Currently working with the API for MapGuide OpenSource 2.0 and have a
requirement for returning all layers from the MapGuide repository.

I am able to return all layer names for a particular map using the below C#
code

            map.Open(resService, mapName);

            MgLayerCollection layers = map.GetLayers();

            ArrayList layerNames = new ArrayList();

            for (int i = 0; i < layers.GetCount(); i++)
            {
                MgLayer layer = (MgLayer)layers.GetItem(i);

                string layerType = layer.GetFeatureGeometryName();
              
                    layerNames.Add(layer.GetName());
            }

How would I go about returning all Layers in the MapGuide repository as a
large number of layers won't be associated with a map?

Many Thanks,

Adnan

-- 
View this message in context:
http://www.nabble.com/Return-all-Layers-from-MapGuide-repository-tp17796701p
17796701.html
Sent from the MapGuide Users mailing list archive at Nabble.com.

_______________________________________________
mapguide-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapguide-users

_______________________________________________
mapguide-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapguide-users

Reply via email to