[mapguide-users] Create map in the session

Kenneth Skovhede, GEOGRAF A/S ks at geograf.dk
Thu Jan 15 11:33:55 EST 2009


When you create the map, using map->Create(...),
you are creating a runtime map located at:
Session:..//mapname.Map

You cannot get the viewer to load this, as it expects a
MapDefinition, and will create the runtime map (and overwrite yours).

I don't know why the SessionID is missing, but it
is correct that you should get an error on the GetResourceContent call.

In the call you wish to make below, make sure that the "MAPNAME" 
parameter is just "mapname", with no session or ".Map" info attached.

Regards, Kenneth Skovhede, GEOGRAF A/S



gingerbbm skrev:
> 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
>
>   


More information about the mapguide-users mailing list