Thursday, 19 January 2012

Some useful tools for debugging your MapGuide Applications

A common problem with MapGuide development is trying to dig into the state of the runtime map, especially when trying to figure out why the new layer you've added to your runtime map is not showing. Here's some useful tools to help you peek into the runtime map.

1. mapinfo.aspx

Get the script here (you will also need the supporting viewresourcecontent.aspx script as well)

This was a script I wrote while porting over the MapGuide Developer's Guide samples to .net (which will be bundled with the next MapGuide Open Source release in *all* languages, instead of just PHP) to help me debug a mysterious bug where newly added layers are shown on the map, but not in the viewer legend. The script accepts two URL parameters:

  • MAPNAME - The name of the runtime map
  • SESSION - The current session id
Invoking this script, gives you a nice detailed view about the state of the given runtime map

You'll notice that the resource ids are hyperlinked. These links call into viewresourcecontent.aspx, which basically shows you the resource content of the hyperlinked resource id.

To set this up, drop mapinfo.aspx and viewresourcecontent.aspx into a directory of your choice. Set this directory up as an application in IIS, then create a bin directory and drop in the MapGuide dlls from your mapviewernet directory.

Then to invoke this script, enter http://url-to-your-directory/mapinfo.aspx?MAPNAME=theMapName&SESSION=your-mapguide-session-id

Because this script takes a MAPNAME and a SESSION parameter. It can automatically be used as an Invoke URL command in your Web Layout. Just create an Invoke URL command that points to mapinfo.aspx, attach it to a toolbar or menu and it is ready to be used in your Web Layout for instant debugging!

2. Runtime Map Inspector

Coming in the next release of Maestro, is a Runtime Map Inspector tool which fulfils the same purpose as mapinfo.aspx. Invoking the tool will bring up the familiar Maestro login (which you are advised to use the Administrator login as that can peek into any user's session repository). Once logged in, a new window will appear where you can fill in the required Map Name and Session ID and then click the Load Map button to bring up the runtime map.

The Runtime Map Inspector will be available in the next release under Tools - Runtime Map Inspector, or by running the RtMapInspector.exe

Hopefully, these new tools will make your MapGuide development experience that much more simpler (if it isn't already!)


Jacqueline said...

Can I use the mapinfo.aspx script on an Apache/php install of MG?

Jackie Ng said...

Sorry, that script will not work in an Apache/PHP setup. I'm looking at making a PHP version of the above script available soon