Dear all

I want to be able to issue the following kind of query from a web
application:

http://.../mapguide2009/mapagent/mapagent.fcgi?GEOMETRY=POLYGON((3 2,4 2,4
3,3 3,3
2))&MAXFEATURES=1&OPERATION=QUERYMAPFEATURES&PERSIST=0&SELECTIONVARIANT=INTERSECTS&MAPNAME=...&SESSION=...&VERSION=1.0.0

For this to work I need a session ID and map name, so I'm trying to create a
map in the session on-the-fly, as follows:

        <?php
        //
        // Vital includes.
        //
        include "constants.php";
        include "common.php";
        include "../fusion/mapguide/php/Utilities.php";

        //
        // Usual initialisation step.
        //
        InitializeWebTier();

        //
        // Obtain a new session ID for this anonymous user, use it to set up
        // a new site connection and use that to create a resource service.
        //
        $site = new MgSite();
        $site->Open(new MgUserInformation("Administrator", "admin"));

        $sessionId = $site->CreateSession();

        $siteConnection = new MgSiteConnection();
        $siteConnection->Open(new MgUserInformation($sessionId));

        $resourceService =
$siteConnection->CreateService(MgServiceType::ResourceService);
        $mdResourceId = new
MgResourceIdentifier("Library://Maps/mapname.MapDefinition");

        $mapName = $mdResourceId->GetName();

        $map = new MgMap();
        $map->Create($resourceService, $mdResourceId, $mapName);

        echo "Name of map:" . $map->GetName() . "<br/>";
        echo "Session ID of map:" . $map->GetSessionId() . "<br/>";
        echo "Object ID: " . $map->GetObjectId() . "<br/>";
        echo "Session ID: " . $sessionId . "<br/>";

        $mapId = new MgResourceIdentifier("Session:$sessionId//$mapName." .
MgResourceType::Map);
        $map->Save($resourceService, $mapId);

        $layerCollection = $map->GetLayers();
        for ($i = 0; $i < $layerCollection->GetCount(); $i++)
        {
                $layer = $layerCollection->GetItem($i);
                echo "      layer #" . ($i + 1) . ": " . $layer->GetName() . 
"<br/>";
        }
        ?>

Although this returns a list of layers as expected, the value returned by
$map->GetSessionId() is blank and I suspect this has something to with why,
having loaded this page, I get the following in the map agent when I submit
a GetResourceContent request on "Session:...//mapname.MapDefinition":

Resource was not found: Session:...//mapname.MapDefinition

What am I missing?

Thanks
Stuart

-- 
View this message in context: 
http://n2.nabble.com/Create-map-in-the-session-tp2163117p2163117.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

Reply via email to