Saving map to session doesn't persist?
Jason Birch
Jason.Birch at nanaimo.ca
Fri Nov 17 12:08:08 EST 2006
I've attached an example that I think should save a MapDefinition to the session repository, but a call to MapAgent to render the map comes up with a MgResourceNotFoundException (I think).
Is there something that says that MapDefinitions need to be modified to be persisted? Is there a typo in there somewhere?
Jason
-------------- next part --------------
<?php
$extensionDir="C:/Program Files/MapGuideOpenSource/WebServerExtensions/www/";
$viewerDir = $extensionDir . "mapviewerphp/";
include $viewerDir . 'common.php';
include $viewerDir . 'constants.php';
try
{
MgInitializeWebTier($extensionDir."webconfig.ini");
$user = new MgUserInformation('Administrator','admin');
$siteConnection = new MgSiteConnection();
$siteConnection->Open($user);
$resourceService = $siteConnection->CreateService (MgServiceType::ResourceService);
$site = $siteConnection->GetSite();
$sessionId = $site->CreateSession();
$user->SetMgSessionId($sessionId);
//Set up the map to be used in this service
$resourceID = new MgResourceIdentifier('Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition');
//Create a connection to the map
$map = new MgMap();
$map->Create($resourceService,$resourceID,'Sheboygan');
//Save the map into the repository
$mapId = new MgResourceIdentifier("Session:$sessionId//Sheboygan.". MgResourceType::Map);
$map->Save($resourceService, $mapId);
$imageURL= "http://localhost/mapguide/mapagent/mapagent.fcgi" .
"?OPERATION=GETMAPIMAGE&VERSION=1.0.0" .
"&MAPNAME=Sheboygan&LOCALE=en".
"&MAPDEFINITION=Session:".
$sessionId."//Sheboygan.". MgResourceType::Map .
"&FORMAT=PNG" .
"&SETVIEWCENTERX=103.88257".
"&SETVIEWCENTERY=1.331479".
"&SETVIEWSCALE=4000&SETDISPLAYDPI=100".
"&SETDISPLAYWIDTH=600&SETDISPLAYHEIGHT=600".
"&SESSION=".$sessionId;
//Output the contents of the request
header("Content-Type : image/png");
print file_get_contents($imageURL);
}
catch (MgException $ex)
{
print "<p>Error: " . $ex->GetMessage() . "<br/>";
print "Details:" . $ex->GetDetails() . "</p>";
exit;
}
More information about the Mapguide_users
mailing list