Building a map with multiple layers

View example

In order to make the map content richer, continue to add new data (river data). There is almost no new point of knowledge here.

Below is the map file (xmfml2.map):

01 MAP
02     IMAGETYPE "PNG"
03     EXTENT -180 -90 180 90
04     SIZE 600 300
05     SHAPEPATH "/gdata"
06     IMAGECOLOR 255 255 255
07     FONTSET "../fonts/fonts.list"
08     LAYER
09         NAME "states_poly"
10         DATA "wcountry.shp"
11         STATUS OFF
12         TYPE POLYGON
13         LABELITEM "NAME"
14         CLASS
15             NAME "States"
16             STYLE
17                 COLOR 232 232 232
18             END
19         END
20     END
21     LAYER
22         NAME "states_line"
23         DATA "wcountry.shp"
24         STATUS OFF
25         TYPE LINE
26         CLASS
27             NAME "State Boundary"
28             STYLE
29                 COLOR 132 132 32
30             END
31         END
32     END
33     LAYER
34         NAME "wroads"
35         DATA "wroads.shp"
36         STATUS OFF
37         TYPE LINE
38         CLASS
39             NAME "World Road"
40             STYLE
41                 COLOR 100 200 100
42             END
43         END
44     END
45     LAYER
46         NAME "wriver"
47         DATA "wriver.shp"
48         STATUS OFF
49         TYPE LINE
50         CLASS
51             NAME "World River"
52             STYLE
53                 COLOR 0 0 255
54             END
55         END
56     END
57 END

The above Mapfile also defines this layer in the map below the road layer map (wroads).

Layer order

Pay attention to the order of the layers. In this map, the river layer is above the road, which is inconsistent with the principle of normal drawing. Usually, the road layer is placed on top of the river layer.

Swap the position when passing the parameters, the effect is as follows, you can see the same as the map above. The order of the layers defined in Mapfile cannot be changed by passing the parameters of the URL.

The order in which you want to modify the layer can only be modified in the Mapfile:

01 MAP
02     IMAGETYPE "PNG"
03     EXTENT -180 -90 180 90
04     SIZE 600 300
05     SHAPEPATH "/gdata"
06     IMAGECOLOR 255 255 255
07     FONTSET "../fonts/fonts.list"
08     LAYER
09         NAME "states_poly"
10         DATA "wcountry.shp"
11         STATUS OFF
12         TYPE POLYGON
13         LABELITEM "NAME"
14         CLASS
15             NAME "States"
16             STYLE
17                 COLOR 232 232 232
18             END
19         END
20     END
21     LAYER
22         NAME "states_line"
23         DATA "wcountry.shp"
24         STATUS OFF
25         TYPE LINE
26         CLASS
27             NAME "State Boundary"
28             STYLE
29                 COLOR 132 132 32
30             END
31         END
32     END
33     LAYER
34         NAME "wriver"
35         DATA "wriver.shp"
36         STATUS OFF
37         TYPE LINE
38         CLASS
39             NAME "World River"
40             STYLE
41                 COLOR 0 0 255
42             END
43         END
44     END
45     LAYER
46         NAME "wroads"
47         DATA "wroads.shp"
48         STATUS OFF
49         TYPE LINE
50         CLASS
51             NAME "World Road"
52             STYLE
53                 COLOR 100 200 100
54             END
55         END
56     END
57 END

It can be seen that, although not obvious, the river layer is below the road layer.