The Mapserver 6.0 release comes with a really useful feature, which they snuck in really quietly but deserves more praise in my opinion: a built-in openlayers viewer.

It’s very simple, and only for testing purposes, but it’s so much easier for debugging your mapserver map file compared to the old “mode=map&layers=all” approach.

The syntax for calling it is very similar to the old “mode=map” approach (split into separate lines for clarity here but in reality all one line):


So you still need the parameter “map=…” but you include “template=openlayers” and change to “mode=browse”.

By default this uses a cut-down copy of the OpenLayers javascript library from but this is no good if, like me, you are often deploying mapserver in a highly controlled environment where external internet access is locked down.

In that case though, you can add an additional parameter to your mapserver map file, pointed at a different location for the openlayers library (split into separate lines for clarity again):


I find it easiest to place the openlayers javascript library inside the mapserver cgi-bin folder as that will definitely be web-enabled in either IIS or Apache.

To make it look really neat, and get the icons for zooming and panning, you can also download the “theme/default/style.css” stylesheet, and the img folder, both from a standard openlayers install or from here and place those two folders (theme and img) inside your chosen openlayers library location too.

I really think there should have been more of a fanfare about this feature. Testing mapserver layers and map files in a browser is one thing that beginners find very difficult, and it’s not exactly easy. This helps immensely.