77 MapServer OpenLayers Viewer
88*****************************************************************************
99
10- MapServer (since the 6.0 release) provides a simple, built-in method for testing a mapfile
10+ MapServer (since the 6.0 release) provides a simple, built-in method for testing a Mapfile
1111using OpenLayers. This feature is for testing/development purposes
1212only, and not for production or deploying full-featured sites. You
13- can preview, test, and navigate a mapfile by accessing a special url
13+ can preview, test, and navigate a Mapfile by accessing a special url
1414which will return a built-in OpenLayers template.
1515
1616.. note:: This feature was discussed in
1717 `rfc 63 <https://mapserver.org/development/rfc/ms-rfc-63.html>`_
1818 and in the ticket https://github.com/MapServer/MapServer/issues/3549
1919
20+ Up to the MapServer 8.4 release the OpenLayers Viewer was based on `OpenLayers 2 <https://openlayers.org/two/>`_.
21+ As of MapServer 8.6 the OpenLayers viewer was updated to work with `OpenLayers 10.4+ <https://openlayers.org/>`_.
22+ The MapServer CGI Layer, used by the viewer, can be see in
23+ the `OpenLayers examples <https://openlayers.org/en/latest/examples/mapserver-cgi.html>`_.
2024
2125Using the OpenLayers viewer
2226-----------------------------------------------------------------------------
@@ -25,7 +29,7 @@ Using the OpenLayers viewer
2529Opening the OpenLayers viewer in your browser
2630~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2731
28- Assuming you are running mapserver on your local machine, and you have
32+ Assuming you are running MapServer on your local machine, and you have
2933the Itasca demo setup, a basic url would be (split into two lines for
3034readability)::
3135
@@ -97,18 +101,32 @@ Here is a quick breakdown of the interesting parts of that URL:
97101Customizing settings
98102~~~~~~~~~~~~~~~~~~~~
99103
100- * environment variables::
104+ The viewer relies on two external files - a JavaScript file and a CSS file. By default these are loaded
105+ from ``https://mapserver.org/lib/``, however you can use your own copies of these files if external network access
106+ is restricted by setting the following two :ref:`environment_variables`:
101107
102- MS_OPENLAYERS_JS_URL - The URL to the OpenLayers javascript library. Per default the library loaded from the MapServer web server.
108+ * ``MS_OPENLAYERS_JS_URL`` - the URL to the OpenLayers JavaScript library.
109+ * ``MS_OPENLAYERS_CSS_URL`` - the URL to the OpenLayers CSS file used for styling.
110+
111+ These variables can also be set in a Mapfile, for example to point to the full OpenLayers build on a CDN
112+ (Content Delivery Network):
113+
114+ .. code-block:: mapfile
115+
116+ CONFIG "MS_OPENLAYERS_CSS_URL" "//cdn.jsdelivr.net/npm/
[email protected] /ol.css"
117+ CONFIG "MS_OPENLAYERS_JS_URL" "//cdn.jsdelivr.net/npm/
[email protected] /dist/ol.js"
103118
104119Location of the embedded OpenLayers.js file
105120-------------------------------------------
106121
107- If you aren't providing your own OpenLayers library through `MS_OPENLAYERS_JS_URL`,
108- MapServer will point to a hardcoded filepath of `www.mapserver.org/lib` to find the OpenLayers
109- library, referred to in [maptemplate.c](https://github.com/MapServer/MapServer/blob/main/src/maptemplate.c#L54).
122+ If you aren't providing your own OpenLayers library through `MS_OPENLAYERS_JS_URL` and
123+ `MS_OPENLAYERS_CSS_URL`, MapServer will point to hardcoded filepaths at `mapserver.org/lib` to find the OpenLayers
124+ library, referred to in `maptemplate.c <https://github.com/MapServer/MapServer/blob/main/src/maptemplate.c#L54>`_.
125+
126+ This version of OpenLayers is a cut-down version that only contains the classes needed for the
127+ MapServer viewer. The ``ol-mapserver.js`` file is ~200 KB compared to the full library which is ~ 840 KB.
110128
111- The contents on that `lib` folder is stored in the MapServer documentation repository,
112- in the [ /extra]( https://github.com/MapServer/MapServer-documentation/tree/main/extra) folder.
129+ The contents of that `lib` folder is stored in the MapServer documentation repository,
130+ in the ` /extra < https://github.com/MapServer/MapServer-documentation/tree/main/extra>`_ folder.
113131You are warmly encouraged to contribute to upgrading the OpenLayers library, at any time (maybe start
114- with creating a new [ Pull Request]( https://github.com/MapServer/MapServer-documentation/pulls) there.
132+ with creating a new ` Pull Request < https://github.com/MapServer/MapServer-documentation/pulls>`_ there) .
0 commit comments