Getting started with Mapfile

Do not use the "map" of the data

Let's take a look at the basic usage of MapServer without using any GIS data.

The image shown above is the code used:

 <img border="1" src="http://drr.ikcest.org/webgis/cgi-bin/mapserv?map=/oswebgis/xmfa0.map&mode=map"/>

Basic usage of Mapfile

In MapServer, to generate the above image, the Mapfile code used is:

01 MAP
02     NAME "Hello World"
03     SIZE 400 200
04     IMAGECOLOR 249 245 186
05     IMAGETYPE "png"
06     EXTENT -1.0 -1.0 1.0 1.0
07     WEB
08         TEMPLATE "/owg/beg_hello.html"
09         IMAGEPATH "/owg/ms_tmp/"
10         IMAGEURL "/ms_tmp/"
11     END
12     LAYER
13         STATUS DEFAULT
14         TYPE POINT
15         FEATURE
16             POINTS
17                 0.0 0.0
18             END
19             TEXT "Hello, MapServer world!"
20         END
21         CLASS
22             STYLE
23                 COLOR 255 0 0
24             END
25             LABEL
26                 TYPE BITMAP
27             END
28         END
29     END
30 END

First Mapfile

Layer objects are defined below the map object. Before you can display a map, you need to define at least one layer in your map file. You can define as many layers as you want in MapServer. By default, the upper limit of the number of layers is defined in the source code map.h and is limited to 100. This restriction can be removed by modifying the source code, but there seems to be no reason to do so.