Web Layouts and MapGuide Server Pages

A MapGuide Server Page is any PHP, ASP.NET, or JSP page that makes use of the MapGuide Web API. These pages are typically invoked by the MapGuide Viewer or browser and when processed result in HTML pages that are loaded into a MapGuide Viewer or browser frame. This is the form that will be used for most examples in this guide. It is possible, however, to create pages that do not return HTML or interact with the Viewer at all. These can be used for creating web services as a back-end to another mapping client or for batch processing of your data.

Creating a MapGuide page requires initial setup, to make the proper connections between the Viewer, the page, and the MapGuide site. Much of this can be done using Studio. Refer to the Studio Help for details.

One part of the initial setup is creating a web layout, which defines the appearance and available functions for the Viewer. When you define a web layout, you assign it a resource name that describes its location in the repository. The full resource name looks something like this:

    Library://Samples/Layouts/SamplesPhp.WebLayout

When you open the web layout using a browser with either the AJAX Viewer or the DWF Viewer, the resource name is passed as part of the Viewer URL. Special characters in the resource name are URL-encoded, so the full URL would look something like this, (with line breaks removed):

    http://localhost/mapguide/mapviewerajax/

    ?WEBLAYOUT=Library%3a%2f%2fSamples%2fSheboygan%2fLayouts%2f

    SheboyganPhp.WebLayout

Part of the web layout defines commands and the toolbars and menus that contain the commands. These commands can be built-in commands, or they can be URLs to custom pages. The web layout also includes a URL to a home task that displays in the task pane. The home task can open other pages.

To create a new page and make it available as a command from the task list, do the following:

- Edit the web layout using Studio.
- Add a command to the web layout.
- Set the command type to Invoke URL.
- Set the URL of the command to the URL of your page.
- Add the command to the Task Bar Menu.

NoteCustom pages are loaded by the Viewer page, so a relative URL for a custom page must start at the Viewer directory, then go up one level to reach the mapguide directory. For example, a custom page located at www/mapguide/samplesphp/index.php would use the following relative URL in the web layout

    ../samplesphp/index.php

It is also possible to add custom commands to the toolbar and the context menu using the same technique.

For most of the examples in this guide, however, the pages will be links from a home page loaded in the task pane frame.

NoteInstalling the package that comes with the Developer’s Guide samples creates a web layout automatically. The home task page of this layout contains links to examples that correspond to chapters in the Developer’s Guide.