MS RFC 63: Built-in OpenLayers map viewer¶
|Author:||Daniel Morissette (dmorissette at mapgears.com)|
|Author:||Alan Boudreault (aboudreault at mapgears.com)|
|Status:||Adopted on 2010-10-29. Implementation complete.|
Users often request for a simple way to test mapfiles. This RFC proposes a simple way to preview, test and navigate a mapfile with MapServer using a built-in OpenLayers based map viewer that will be triggered via the cgi. This is for testing/development purposes only and not for production or deploying full-featured sites. This will use the a built-in openlayers template. It will return a simple html viewer based on OpenLayers.
Note that GeoServer already provides a similar functionality and this is what this RFC was inspired from.
In order to implement this enhancement, the following changes should be made in the MapServer codebase:
Add a built-in openlayers template.
Some new template tags will be needed. These tags will be used to construct the mapserver cgi url.
See ticket 3552 for more detail.
The template will be triggered using one of the following ways:
- Using mode=browse&template=openlayers: The viewer will be initialized based on the mapfile defaults, and some of the traditional mapserv CGI params may also work (such as map size, layer selection, etc.)
- Using FORMAT=application/openlayers in a WMS GetMap request: The rest of the GetMap parameters would be used to configure the map to view (BBOX, WIDTH, HEIGHT, LAYERS, etc.)
Both cases would call the same functions internally to produce a simple OpenLayers viewer with one singletile layer for the whole map with the selected layers.
Here’s the simple viewer html code that could be used:
Users will also be able to use their own OpenLayers library in one of two ways:
- Using a environment variable: by setting the environment variable MS_OPENLAYERS_JS_URL, MapServer will use that url rather than the default one.
- Using a CONFIG setting in the mapfile: by adding the config variable MS_OPENLAYERS_JS_URL in a mapfile, MapServer will use that url rather than the default one.
In the future, we may provide a mechanism to support multiple frameworks and ship generic templates with MapServer.
The ticket for RFC-63 (containing the implementation) can be found here.
Adopted on 2010-10-29 with +1 from SteveL, DanielM, JeffK, AssefaY, TomK, TamasS, SteveW and PerryN.