You can use the EnumerateResources function.
I belive it is in the MgResourceService.

Beware though, that the layers you show below are runtime map layers, whereas the layers in the repository are layerdefinitions.
The layerdefinitions are all xml files.

I have built an API that handles this Xml in a more accesible way:
http://trac.osgeo.org/mapguide/wiki/maestro/MaestroAPI/basics

With MaestroAPI, you can get all the layers in the server with this code:

MaestroAPI.ServerConnectionI connection = new 
MaestroAPI.LocalNativeConnection(configfile, username, password, locale);
foreach(ResourceListResourceDocument doc in con.GetRepositoryResources("Library://", 
"LayerDefinition"))
{
        LayerDefinition layer = connection.GetLayerDefinition(doc.ResourceId);
        if (layer.Item as VectorLayerDefinition != null)
        {
                string layerType = (layer.Item as 
VectorLayerDefinition).Geometry;
        }
}


Regards, Kenneth Skovhede, GEOGRAF A/S



adnan.c skrev:
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

_______________________________________________
mapguide-users mailing list
mapguide-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapguide-users

Reply via email to