Static map using two layers

View example

In this example, the image is generated into the source <img> tag of this URL connection:

 //drr.ikcest.org/webgis/cgi-bin/mapserv?map=/oswebgis/xmfa2.map&layer=world-country&layer=country-line&mode=map

Most traditional MapServer examples will be shown this way.

This example is slightly different from the previous one, and the color of the polygon has been modified.

Mapfile Description

First look at the MapFile (xmfa2.map) used in this example:

01 MAP
02     IMAGETYPE "PNG"
03     EXTENT -180 -90 180 90
04     SIZE 600 300
05     SHAPEPATH "/gdata"
06     IMAGECOLOR 255 255 255
07     LAYER
08         NAME "world-country"
09         DATA "wcountry.shp"
10         STATUS OFF
11         TYPE POLYGON
12         CLASS
13             NAME "States"
14             STYLE
15                 COLOR 232 232 232
16             END
17         END
18     END
19     LAYER
20         NAME "country-line"
21         DATA "wcountry.shp"
22         STATUS OFF
23         TYPE LINE
24         CLASS
25             NAME "State Boundary"
26             STYLE
27                 COLOR 132 132 32
28             END
29         END
30     END
31 END

second Mapfile

The structure of MapFile looks like this:


               MAP
          LAYER-|-LAYER
        CLASS-|   |-CLASS
      STYLE-|       |-STYLE

Compared with the previous Mapfile, the changes are as follows:

12        CLASS12        CLASS
n13            NAME "The Upper Great Lakes States"n13            NAME "States"
14            STYLE14            STYLE
15                COLOR 232 232 23215                COLOR 232 232 232
tt16            END
17        END
18    END
19    LAYER
20        NAME "country-line"
21        DATA "wcountry.shp"
22        STATUS OFF
23        TYPE LINE
24        CLASS
25            NAME "State Boundary"
26            STYLE
16                OUTLINECOLOR 32 32 3227                COLOR 132 132 32
17            END28            END

Here, the original layer is divided into two layers. The first layer is still a polygon layer, but there is no longer a OUTLINECOLOR attribute in the style. The TYPE of the second layer is LINE, and the value of the color is different from the color of OUTLINECOLOR in the first example. This will produce an image that is slightly different from the first example.

Further explanation

Here is an explanation of why this is done. If we continue to add layers on top of the layer, the outlines are most likely to be masked. In order to be able to see the borderline, add other layers, we have to separate the borderline layer from the state polygon layer and place it on top of the other layers. How to define/add layers is sequential, as will be explained later. Here you only need to follow the "latecomers" (the layers defined later will be displayed above).