Hello, Map – Displaying a Web Layout

A web layout describes how the map looks when it is displayed in a web browser. Using Infrastructure Studio or some other method to edit the web layout resource, you can create and customize the layout, changing how it looks in a browser and what features are enabled. This section describes displaying a Web Layout using the Basic Layout viewer.

Displaying the web layout requires a compatible web browser and a viewer. The Viewer does not require installing any additional software. It runs using most browsers, including Internet Explorer, Mozilla Firefox, Google Chrome, and Apple Safari.

Note: Refer to the system requirements for the supported version of each browser.

The simplest way to display a web layout is to pass its resource identifier as a GET parameter to the Viewer URL. For example, the following will display a web layout using the Viewer running on localhost:

http://localhost/mapserver2013/mapviewerajax/?
WEBLAYOUT=Library%3a%2f%2fSamples%2fLayouts%2fSample.WebLayout

Authentication

All Infrastructure Map Server sites require authentication with user id and password. If authentication succeeds, Infrastructure Map Server creates a session, identified by a unique session id. This keeps the state consistent between the viewer and the server across multiple HTTP requests. Subsequent access to the site requires the session id instead of the user id. By default, the Viewer handles authentication itself, and it prompts for user id and password when it first loads. There are situations, though, where it is better to authenticate before loading the Viewer page.

One common example is a site offering read-only access to visitors. For this situation, the default Infrastructure Map Server installation includes a user “Anonymous” with an empty password.

To perform authentication before the Viewer loads, embed the Viewer in another page using a <frame> or <iframe> element. The outer page can do any necessary authentication, create a session, then pass the web layout and session id to the Viewer frame.

The following example displays a web layout using the Viewer. It performs some basic initialization and creates a session, then displays a Viewer page using the session identifier and the web layout.

<?php
 
$installDir =
   'C:\Program Files\Autodesk\Autodesk Infrastructure Web Server Extension 2016\\';
$extensionsDir = $installDir . 'WebServerExtensions\www\\';
$viewerDir = $installDir . 'mapviewerphp\\';
 
include $viewerDir . 'constants.php';
 
MgInitializeWebTier($extensionsDir . 'webconfig.ini');
 
$site = new MgSite();
$site->Open(new MgUserInformation("Anonymous", ""));
 
$sessionId = $site->CreateSession();
$webLayout = 
   "Library://Samples/Layouts/SamplesPhp.WebLayout";
 
?>
 
<html>
 
<head>
<title>Simple Sample Application</title>
</head>
 
<body marginheight="0" marginwidth="0">
<iframe id="viewerFrame" width="100%" height="100%" frameborder=0 
   scrolling="no" 
   src="/mapserver2012/mapviewerajax/?SESSION=<?= $sessionId ?>&
   WEBLAYOUT=<?= $webLayout ?>"></iframe>
</body>
</html>