A web layout describes how the map looks when it is displayed in a web browser. Using 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.
Displaying the web layout requires a compatible web browser and a MapGuide Viewer. There are two Viewers, depending on the needs of your site. The DWF Viewer runs as a control within the Internet Explorer browser. It requires that users install the Autodesk DWF Viewer.
The AJAX Viewer does not require installing any additional software. It runs using most browsers, including Internet Explorer, Mozilla Firefox, and Safari.
localhost:
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 AJAX Viewer running onhttp://localhost/mapguide/mapviewerajax/?
WEBLAYOUT=Library%3a%2f%2fSamples%2fLayouts%2fSample.WebLayout
All MapGuide sites require authentication with user id and password. If authentication succeeds, MapGuide 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 MapGuide installation includes a user “Anonymous” with an empty password.
<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.
To perform authentication before the Viewer loads, embed the Viewer in another page using aThe following example displays a web layout using the AJAX 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\MapGuideOpenSource\\';
$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="/mapguide/mapviewerajax/?SESSION=<?= $sessionId ?>&
WEBLAYOUT=<?= $webLayout ?>"></iframe>
</body>
</html>