Getting Layer and Group ids from Viewer Server Side Components.

4 messages Options
Embed this post
Permalink
Carl Jokl

Getting Layer and Group ids from Viewer Server Side Components.

Reply Threaded More More options
Print post
Permalink
I am currently working on some .Net based stress testing tools. I have used and example MapGuide testing Grinder application. I adapted a lot of this to work with our existing .Net based MapGuide framework. One thing I still need to do though if have a way to get hold of layer ids (and group ids) for use in the code for turning layers and groups on and off. It seems that these ids seem to be generated when the application is running. Logically if the AJAX viewer has access to them it must have been able to get hold of them from one of the server data pages or data portals. The question is how to invoke the server in a similar fashion to which Ajax viewer does to get hold of the layer and layer group ids for the currently loaded map in the current session.

Has anyone done this. I am going to look at the client side JavaScript code to try and find clues but if anyone has already done this they might be able to give me some pointers.
zspitzer

Re: Getting Layer and Group ids from Viewer Server Side Components.

Reply Threaded More More options
Print post
Permalink
in php based off some of the samples

$layerCollection = $map->GetLayers();
PrintLayerCollection($layerCollection);
$map->Save($resourceService, $mapStateId);

function PrintLayerCollection($layerCollection)
{
        for ($i = 0; $i < $layerCollection->GetCount(); $i++)
        {
            $layer = $layerCollection->GetItem($i);
            PrintLayer($layer);
        }
}

function PrintLayer($layer)
{
    echo $layer->GetName() . ':'.$layer->GetObjectId() . ";\n";
}

z



On Mon, Sep 7, 2009 at 10:34 PM, Carl Jokl<[hidden email]> wrote:

>
> I am currently working on some .Net based stress testing tools. I have used
> and example MapGuide testing Grinder application. I adapted a lot of this to
> work with our existing .Net based MapGuide framework. One thing I still need
> to do though if have a way to get hold of layer ids (and group ids) for use
> in the code for turning layers and groups on and off. It seems that these
> ids seem to be generated when the application is running. Logically if the
> AJAX viewer has access to them it must have been able to get hold of them
> from one of the server data pages or data portals. The question is how to
> invoke the server in a similar fashion to which Ajax viewer does to get hold
> of the layer and layer group ids for the currently loaded map in the current
> session.
>
> Has anyone done this. I am going to look at the client side JavaScript code
> to try and find clues but if anyone has already done this they might be able
> to give me some pointers.
> --
> View this message in context: http://n2.nabble.com/Getting-Layer-and-Group-ids-from-Viewer-Server-Side-Components-tp3597110p3597110.html
> Sent from the MapGuide Internals mailing list archive at Nabble.com.
> _______________________________________________
> mapguide-internals mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/mapguide-internals
>



--
Zac Spitzer -
http://zacster.blogspot.com
+61 405 847 168
_______________________________________________
mapguide-internals mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/mapguide-internals
Carl Jokl

Re: Getting Layer and Group ids from Viewer Server Side Components.

Reply Threaded More More options
Print post
Permalink

zspitzer wrote:
in php based off some of the samples

$layerCollection = $map->GetLayers();
PrintLayerCollection($layerCollection);
$map->Save($resourceService, $mapStateId);

function PrintLayerCollection($layerCollection)
{
        for ($i = 0; $i < $layerCollection->GetCount(); $i++)
        {
            $layer = $layerCollection->GetItem($i);
            PrintLayer($layer);
        }
}

Thank You. That is helpful. I am curious about how the AJAX viewer is getting hold of the object ids but I can have a look and try to find out.

function PrintLayer($layer)
{
    echo $layer->GetName() . ':'.$layer->GetObjectId() . ";\n";
}

z



On Mon, Sep 7, 2009 at 10:34 PM, Carl Jokl<carl.jokl@keynetix.com> wrote:
>
> I am currently working on some .Net based stress testing tools. I have used
> and example MapGuide testing Grinder application. I adapted a lot of this to
> work with our existing .Net based MapGuide framework. One thing I still need
> to do though if have a way to get hold of layer ids (and group ids) for use
> in the code for turning layers and groups on and off. It seems that these
> ids seem to be generated when the application is running. Logically if the
> AJAX viewer has access to them it must have been able to get hold of them
> from one of the server data pages or data portals. The question is how to
> invoke the server in a similar fashion to which Ajax viewer does to get hold
> of the layer and layer group ids for the currently loaded map in the current
> session.
>
> Has anyone done this. I am going to look at the client side JavaScript code
> to try and find clues but if anyone has already done this they might be able
> to give me some pointers.
> --
> View this message in context: http://n2.nabble.com/Getting-Layer-and-Group-ids-from-Viewer-Server-Side-Components-tp3597110p3597110.html
> Sent from the MapGuide Internals mailing list archive at Nabble.com.
> _______________________________________________
> mapguide-internals mailing list
> mapguide-internals@lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapguide-internals
>



--
Zac Spitzer -
http://zacster.blogspot.com
+61 405 847 168
_______________________________________________
mapguide-internals mailing list
mapguide-internals@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapguide-internals
Carl Jokl

Re: Getting Layer and Group ids from Viewer Server Side Components.

Reply Threaded More More options
Print post
Permalink
In the end to save having to create any special server side components I wrote a C# based parser which parses the legend script page directly and can parse the layers and groups directly from the JavaScript declarations in this code. It might not be the most efficient but it does mean I can just point the load tester against any MapGuide site and it should work.