次のサンプルに、基本的なページの構造を示します。このページは、ビューアからタスクとして呼び出されるように設計されています。Infrastructure Map Server サーバに接続し、現在ビューアで表示されているマップの名前と空間参照方式を表示します。
このサンプルは、『開発者用ガイド』のサンプルに含まれている Hello Map サンプルとよく似ています。
<html> <head><title>Hello, map</title></head> <body> <p> <?php // Define some common locations $installDir = 'C:\Program Files\Autodesk\Autodesk Infrastructure Web Server Extension 2016\\'; $extensionsDir = $installDir . 'WebServerExtensions\www\\'; $viewerDir = $extensionsDir . 'mapviewerphp\\'; // constants.php is required to set some enumerations // for PHP. The same step is not required for .NET // or Java applications. include $viewerDir . 'constants.php'; try { // Get the session information passed from the viewer. $args = ($_SERVER['REQUEST_METHOD'] == "POST") ? $_POST : $_GET; $mgSessionId = $args['SESSION'] $mgMapName = $args['MAPNAME'] // Basic initialization needs to be done every time. MgInitializeWebTier("$extensionsDir\webconfig.ini"); // Get the user information using the session id, // and set up a connection to the site server. $userInfo = new MgUserInformation($mgSessionId); $siteConnection = new MgSiteConnection(); $siteConnection->Open($userInfo); // Get an instance of the required service(s). $resourceService = $siteConnection-> CreateService(MgServiceType::ResourceService); // Display the spatial reference system used for the map. $map = new MgMap(); $map->Open($resourceService, $mgMapName); $srs = $map->GetMapSRS(); echo 'Map <strong>' . $map->GetName() . '</strong> uses this reference system: <br />' . $srs; } catch (MgException $e) { echo "ERROR: " . $e->GetMessage() . "<br />"; echo $e->GetStackTrace() . "<br />"; } ?> </p> </body> </html>