2.9. Use custom styles in Mapfile#
Vector data can be divided into three types: point, line and surface. The simplicity of the data type structure gives the diversity of expression. In MapServer, you can set styles in various dimensions such as color, size (thickness), and transparency for points, lines, and surfaces.
2.9.1. Point#
The Mapfile used is:
1MAP
2 IMAGETYPE "PNG"
3 EXTENT -180 -90 180 90
4 SIZE 600 300
5 SHAPEPATH "/gdata"
6 IMAGECOLOR 255 255 255
7 SYMBOL
8 NAME "circle"
9 TYPE ELLIPSE
10 FILLED TRUE
11 POINTS
12 10 10
13 END
14 END
15 LAYER
16 NAME "world-country"
17 DATA "wcountry.shp"
18 STATUS OFF
19 TYPE POLYGON
20 CLASS
21 NAME "The Upper Great Lakes States"
22 STYLE
23 COLOR 232 232 232
24 OUTLINECOLOR 32 32 32
25 END
26 END
27 END
28 LAYER
29 NAME "world-city"
30 DATA "world/cities.shp"
31 STATUS OFF
32 TYPE POINT
33 CLASS
34 NAME "cities"
35 SYMBOL "circle"
36 SIZE 6
37 COLOR 0 0 0
38 END
39 END
40END
2.9.2. Line fill example#
The Mapfile used is:
1MAP
2 IMAGETYPE "PNG"
3 EXTENT -180 -90 180 90
4 SIZE 600 300
5 SHAPEPATH "/gdata"
6 IMAGECOLOR 255 255 255
7 SYMBOL
8 NAME "hatch-test"
9 TYPE HATCH
10 END
11 LAYER
12 NAME "world-country"
13 DATA "wcountry.shp"
14 STATUS OFF
15 TYPE POLYGON
16 CLASS
17 NAME "The Upper Great Lakes States"
18 STYLE
19 SYMBOL "hatch-test"
20 COLOR 255 0 0
21 ANGLE 45
22 SIZE 10
23 WIDTH 3
24 END
25 END
26 END
27END
2.9.3. Circular fill exampl#
The Mapfile used is:
1MAP
2 IMAGETYPE "PNG"
3 EXTENT -180 -90 180 90
4 SIZE 600 300
5 SHAPEPATH "/gdata"
6 IMAGECOLOR 255 255 255
7 SYMBOL
8 NAME "circle"
9 TYPE ELLIPSE
10 FILLED TRUE
11 POINTS
12 1 1
13 END
14 END
15 LAYER
16 NAME "world-country"
17 DATA "wcountry.shp"
18 STATUS OFF
19 TYPE POLYGON
20 CLASS
21 NAME "The Upper Great Lakes States"
22 STYLE
23 SYMBOL "circle"
24 COLOR 255 0 0
25 ANGLE 45
26 SIZE 10
27 WIDTH 3
28 END
29 END
30 END
31END
2.9.4. River style#
The Mapfile used is:
1MAP
2 IMAGETYPE "PNG"
3 EXTENT -180 -90 180 90
4 SIZE 600 300
5 SHAPEPATH "/gdata"
6 IMAGECOLOR 255 255 255
7 FONTSET "../fonts/fonts.list"
8 WEB
9 METADATA
10 "wms_title" "WMS Demo Server"
11 "wms_onlineresource" "//webgis.pub/cgi-bin/mapserv?map=/owg/mfb1.map&"
12 "ows_onlineresource" "//webgis.pub/cgi-bin/mapserv?map=/owg/mfb1.map&"
13 "wms_srs" "EPSG:4269 EPSG:4326"
14 "wms_enable_request" "* !GetFeatureInfo"
15 END
16 END
17 PROJECTION
18 "init=epsg:4326"
19 END
20 LAYER
21 NAME "states_poly"
22 DATA "wcountry.shp"
23 STATUS OFF
24 TYPE POLYGON
25 LABELITEM "NAME"
26 CLASS
27 NAME "States"
28 STYLE
29 COLOR 232 232 232
30 END
31 END
32 END
33 LAYER
34 NAME "states_line"
35 DATA "wcountry.shp"
36 STATUS OFF
37 TYPE LINE
38 CLASS
39 NAME "State Boundary"
40 STYLE
41 COLOR 132 132 32
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 LAYER
58 NAME "wroads"
59 DATA "wroads.shp"
60 STATUS OFF
61 TYPE LINE
62 CLASS
63 NAME "World Road"
64 STYLE
65 COLOR 100 100 100
66 WIDTH 1
67 LINECAP BUTT
68 PATTERN
69 10 5
70 5 10
71 END
72 END
73 END
74 END
75END
GepMap
can be further used to get the effect of the magnification: