@@ -14,9 +14,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
17- `rfc 63 <https://mapserver.org/development/rfc/ms-rfc-63.html>`_
17+ `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-dev the OpenLayers viewer was updated to work with `OpenLayers 10.5+ <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,38 +29,41 @@ 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
29- the Itasca demo setup, a basic url would be (split into two lines for
30- readability)::
32+ Assuming you are running MapServer on your local machine, and you have
33+ the Itasca demo setup, a basic URL would be::
3134
32- http://localhost/cgi-bin/mapserv?mode=browse&template=openlayers
33- &layer=lakespy2&layer=dlgstln2&map=/var/www/workshop/itasca.map
35+ http://localhost/cgi-bin/mapserv?mode=browse&template=openlayers&layer=lakespy2&layer=dlgstln2&map=/var/www/workshop/itasca.map
3436
35- Here is a quick breakdown of that url :
37+ Here is a quick breakdown of that URL :
3638
3739* Basic Parameters for activating the OpenLayers browser::
3840
3941 template=openlayers
4042 mode=browse
4143
4244
43- * Basic Map / Layer Parameters ::
45+ * Basic Map / Layer parameters ::
4446
4547 map=/var/www/workshop/itasca.map
4648 layer=lakespy2
4749 layer=dlgstln2
4850
49- **That's it!**
51+ When using the ``mode=browse`` MapServer will create an image on the server. By default this will be in the same folder as the Mapfile.
52+ If this MapServer cannot write to this folder you will see an error similar to:
53+
54+ .. code-block:: bash
55+
56+ msSaveImage(): Unable to access file. Failed to create output file (/etc/mapserver/Test174833722471.png).
5057
51- .. uncomment me when the demo server is up to 6.0
52- .. If you don't have a live MapServer install to play with, you can also try this out on the demo server::
53- ..
54- .. https://demo.mapserver.org/cgi-bin/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&BBOX=-180,-90,180,90&SRS=EPSG:4326&WIDTH=953&HEIGHT=480&LAYERS=bluemarble,continents,country_bounds,cities&STYLES=&FORMAT=image/png&TRANSPARENT=true&mode=browse&template=openlayers
55- ..
58+ In this case you will need to set your :ref:`IMAGEPATH <mapfile-web-imagepath>` to a folder MapServer can write to.
59+
60+ **That's it!**
5661
62+ If you don't have a live MapServer install to play with, you can also try the
63+ `MapServer demo <https://demo.mapserver.org/cgi-bin/wms?mode=browse&template=openlayers&layer=continents&layer=country_bounds>`__.
5764
5865Opening the OpenLayers viewer in the form of a WMS request
59- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
66+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6067
6168This feature is useful when debugging WMS requests. You can write one
6269of these by hand, or copy the URL for a WMS tile. Running the
@@ -81,32 +88,47 @@ Here is a quick breakdown of the interesting parts of that URL:
8188
8289* Basic WMS parameters::
8390
84- #Layers, our bounding box and projection
91+ # Layers, our bounding box and projection
8592 LAYERS=lakespy2
8693 BBOX=429956.19803725,5231780.0814818,444078.32296225,5245902.2064068
8794 SRS=EPSG:26915
8895
89- #Version and other WMS request params
96+ # Version and other WMS request parameters
9097 SERVICE=WMS
91- VERSION=1.1.1
98+ VERSION=1.3.0
9299 REQUEST=GetMap
93100 WIDTH=512
94101 HEIGHT=512
95102 TRANSPARENT=true
103+ CRS=EPSG:4326
104+ BBOX=-90,-180,90,180
105+ STYLES=
106+
107+ If you don't have a live MapServer install to play with, you try the
108+ `MapServer demo <https://demo.mapserver.org/cgi-bin/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&BBOX=-90,-180,90,180&CRS=EPSG:4326&WIDTH=953&HEIGHT=480&LAYERS=bluemarble,continents,country_bounds,cities&STYLES=&FORMAT=application/openlayers&TRANSPARENT=true`__.>`__.
96109
97110Customizing settings
98111~~~~~~~~~~~~~~~~~~~~
99112
100113* environment variables::
101114
102- MS_OPENLAYERS_JS_URL - The URL to the OpenLayers javascript library. Per default the library loaded from the MapServer web server.
115+ * ``MS_OPENLAYERS_JS_URL`` - the URL to the OpenLayers JavaScript library.
116+ * ``MS_OPENLAYERS_CSS_URL`` - the URL to the OpenLayers CSS file used for styling.
117+
118+ These variables can also be set in a mapfile, for example to point to the full OpenLayers build on a CDN
119+ (Content Delivery Network):
120+
121+ .. code-block:: mapfile
122+
123+ CONFIG "MS_OPENLAYERS_CSS_URL" "//cdn.jsdelivr.net/npm/
[email protected] /ol.css"
124+ CONFIG "MS_OPENLAYERS_JS_URL" "//cdn.jsdelivr.net/npm/
[email protected] /dist/ol.js"
103125
104126Location of the embedded OpenLayers.js file
105127-------------------------------------------
106128
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) .
129+ If you aren't providing your own OpenLayers library through `` MS_OPENLAYERS_JS_URL`` and
130+ ``MS_OPENLAYERS_CSS_URL``, MapServer will point to hard-coded filepaths at ` mapserver.org/lib` to find the OpenLayers
131+ library, referred to in ` maptemplate.c < https://github.com/MapServer/MapServer/blob/main/src/maptemplate.c#L54>`_ .
110132
111133The contents on that `lib` folder is stored in the MapServer documentation repository,
112134in the [/extra](https://github.com/MapServer/MapServer-documentation/tree/main/extra) folder.
0 commit comments