Thursday, 20 November 2014

MapGuide tidbits: Log monitoring with

If the previous MapGuide log monitoring solution don't cut it for you (especially on Linux), here's another one you can try. is a real-time log monitoring solution that runs in your web browser. It is powered by node.js and

Just a note before we dive in, this post is geared towards Linux-specific installations of MapGuide. This may or may not work for Windows. The install instructions assume Linux, so we're rolling with that.

To install you will first have to install node.js, there's a bajillion different links out there on how to install node.js, so here's one for:

Once node is installed, you can install the package via npm (on Ubuntu you'll have to elevate that command with sudo):

npm install -g --user "[username that will run]"

Then start the server.

Then create a harvester.conf in your ~/ directory that defines what log files to monitor. Here's a basic example configured for MapGuide and Apache log monitoring.

exports.config = {
    nodeName: "mapguide_server",
    logStreams: {
      apache: [
      mapguide_access: [
      mapguide_error: [
    server: {
      host: '',
      port: 28777

Now start the log harvester.

Now browse to http://localhost:28778 and watch your MapGuide log files in real time.

NOTE: The above install instructions were pilfered from the website itself, however I found the global install option to be problematic on my Ubuntu test VM. For some reason it always insists on building the native modules as the "root" user and not the user I designated from the npm install command. So I went for a local install instead, which means the following commands have been changed to the following:

  • Installing npm install
  • Running server: ~/node_modules/
  • Running harvester: ~/node_modules/

Friday, 7 November 2014

Announcing: mapguide-rest 0.11.2

Here's another release of mapguide-rest. There was some issues that cropped up after pushing the original 0.11 release that necessitated 2 emergency point releases to fix. As a result, 0.11.2 is the official release.

Here's what's new in this release.

KML Service Support

mapguide-rest now provides RESTful routes that wrap the existing KML Service APIs in MapGuide:

  • /library/{resourcePath}.MapDefinition/kml
  • /library/{resourcePath}.LayerDefinition/kml
  • /library/{resourcePath}.LayerDefinition/kmlfeatures
These routes respectively wrap or replicate:
  • GetMapKml (re-implemented in PHP to write the correct RESTful URLs for NetworkLink) elements)
  • GetLayerKml (re-implemented in PHP to write the correct RESTful URLs for NetworkLink) 
  • GetFeaturesKml (wraps existing API)

Pagination support for feature data routes

These following routes that return feature data now support pagination:

  • /library/{resourcePath}.FeatureSource/features/{schema}/{class}
  • /library/{resourcePath}.FeatureSource/features.{type}/{schema}/{class}
  • /library/{resourcePath}.LayerDefinition/features
  • /library/{resourcePath}.LayerDefinition/features.{type}
  • /session/{sessionID}/{mapName}.Selection/features/{layerName}
  • /session/{sessionID}/{mapName}.Selection/features.{type}/{layerName}

You can paginate the results by passing two additional parameters:

  • pagesize - The number of features to return per "page"
  • page - The page "number" to return
Pagination will work for any supported representation except for CZML. The implementation of CZML output is not compatible with our pagination and errors will be thrown if attempting to pass in pagination parameters for CZML output.

The primary beneficiary of pagination support is ...

HTML representation for feature data

We've added HTML representations for feature data routes:
  • /library/{resourcePath}.FeatureSource/features.{type}/{schema}/{class}
  • /library/{resourcePath}.LayerDefinition/features.{type}
  • /session/{sessionID}/{mapName}.Selection/features.{type}/{layerName}
Where {type} can now be html in addition to the existing supported representations.

For example, a html representation of a Layer Definition would look like this

Apply pagination, and you now have a page-able view of your feature data

The real payoff for implementing this feature is that you also get this support for selected features. For selected features, we support changing the display orientation in the HTML representation as well.

Tweak the page size and orientation parameters for this route and you have what is now effectively a selected feature property palette for your custom map viewer for free, as demonstrated in a new sample that is bundled with this release.

The palette in this sample is just an iframe to this new HTML representation URL.

Improved HTML repository view

The HTML repository representation has been cleaned up

You'll notice each resource no longer show all actionable links. That's because these have been moved to a separate page that is loaded when you click on the resource link.

Clicking on any actionable link will show the result in the space below

We've also added more actionable links for the following resource types:

  • Feature Sources: View features as HTML
  • Map Definitions: Export as KML

Various other HTML representations have also cleaned up css.


mapguide-rest is now localization ready. If you want to translate mapguide-rest to your language of choice, you just have to do the following:

  • Translate and copy the strings in app\res\lang\en.php to app\res\lang\{locale}.php. A small caveat with translating these strings is that you will have to translate the content in a way that respects the ordering of placeholder tokens as we use sprintf to fetch and format localizable strings.
  • Translate and copy the system templates under app\res\templates\en to app\res\templates\{locale}
  • Translate and copy the XSLT templates under app\res\xsl\en to app\res\xsl\{locale}

Once you have translated these files, simply change the Locale property to {locale} in app\config.php and mapguide-rest will use the translated strings and templates

Other changes/fixes

  • Client agent and IP addresses are now recorded when creating a site connection, ensuring all API access from mapguide-rest will be properly logged in the server's access.log
  • Fix layered PDF plotting for maps with base layer groups
  • Added various bits of missing REST API documentation
  • Error messages will now be returned in the appropriate requested format where applicable (eg. If an error occurs when making a request to a URL expecting an XML response, the error will be returned as XML). If no applicable request format can be determined, then the default error response will be in HTML.