MapServer交互操作:地图图例

如何添加地图图例


这里是对应文件:

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     TEMPLATEPATTERN "tmpl-*"
09     LEGEND
10         KEYSIZE 12 12
11         LABEL
12             TYPE BITMAP
13             SIZE MEDIUM
14             COLOR 0 0 89
15         END
16         STATUS ON
17     END
18     SYMBOL
19         NAME "star"
20         TYPE VECTOR
21         FILLED TRUE
22         POINTS
23             0 0.375
24             0.35 0.375
25             0.5 0
26             0.65 0.375
27             1 0.375
28             0.75 0.625
29             0.875 1
30             0.5 0.75
31             0.125 1
32             0.25 0.625
33         END
34     END
35     REFERENCE
36         IMAGE "../images/worldref.png"
37         SIZE 300 150
38         EXTENT -180 -90 180 90
39         STATUS ON
40         MINBOXSIZE 30
41         MAXBOXSIZE 150
42         COLOR 255 255 0
43         OUTLINECOLOR 255 50 50
44         MARKERSIZE 30
45         MARKER "star"
46     END
47     SCALEBAR
48         IMAGECOLOR 255 255 255
49         LABEL
50             COLOR 0 0 0
51             SIZE TINY
52         END
53         STYLE 1
54         SIZE 160 2
55         COLOR 0 0 0
56         UNITS KILOMETERS
57         INTERVALS 2
58         TRANSPARENT FALSE
59         STATUS ON
60     END
61     WEB
62         TEMPLATE "to be replaced by map_web_template variable in section2.html"
63         IMAGEPATH "/owg/ms_tmp/"
64         IMAGEURL "/ms_tmp/"
65         METADATA
66             "wms_title" "WMS Demo Server"
67             "wms_onlineresource" "http://192.168.4.211/cgi-bin/mapserv?map=/mstu/htdocs/example2.map&"
68             "wms_srs" "EPSG:3857 EPSG:4326"
69         END
70     END
71     LAYER
72         NAME "land"
73         DATA "land_shallow_topo_8192.tif"
74         STATUS OFF
75         TYPE RASTER
76     END
77     LAYER
78         NAME "topo"
79         TYPE RASTER
80         CONNECTIONTYPE WMS
81         CONNECTION "http://wcs.osgeo.cn:8088/service?"
82         METADATA
83             "wms_srs" "EPSG:4326"
84             "wms_name" "maplet_i887"
85             "wms_server_version" "1.1.1"
86             "wms_format" "image/jpeg"
87         END
88         PROJECTION
89             "init=epsg:4326"
90         END
91     END
92     LAYER
93         NAME "states_poly"
94         DATA "wcountry.shp"
95         STATUS OFF
96         TYPE POLYGON
97         LABELITEM "NAME"
98         CLASS
99             NAME "States"
100             STYLE
101                 COLOR 232 232 232
102             END
103         END
104     END
105     LAYER
106         NAME "states_line"
107         DATA "wcountry.shp"
108         STATUS OFF
109         TYPE LINE
110         CLASS
111             NAME "State Boundary"
112             STYLE
113                 COLOR 132 132 32
114             END
115         END
116     END
117     LAYER
118         NAME "wriver"
119         DATA "wriver.shp"
120         STATUS OFF
121         TYPE LINE
122         CLASS
123             NAME "World River"
124             STYLE
125                 COLOR 0 0 255
126             END
127         END
128     END
129     LAYER
130         NAME "wroads"
131         DATA "wroads.shp"
132         STATUS OFF
133         TYPE LINE
134         CLASS
135             NAME "World Road"
136             STYLE
137                 COLOR 100 200 100
138             END
139         END
140     END
141 END

你可以在这里看到 HTML Template 源代码.

7    FONTSET "../fonts/fonts.list"7    FONTSET "../fonts/fonts.list"
n8    PROJECTIONn8    TEMPLATEPATTERN "tmpl-*"
9        "init=epsg:4326"9    LEGEND
10        KEYSIZE 12 12
11        LABEL
12            TYPE BITMAP
13            SIZE MEDIUM
14            COLOR 0 0 89
15        END
16        STATUS ON
10    END17    END
n11    TEMPLATEPATTERN "tmpl-*"n
12    SYMBOL18    SYMBOL
39        MARKER "star"45        MARKER "star"
nn46    END
47    SCALEBAR
48        IMAGECOLOR 255 255 255
49        LABEL
50            COLOR 0 0 0
51            SIZE TINY
52        END
53        STYLE 1
54        SIZE 160 2
55        COLOR 0 0 0
56        UNITS KILOMETERS
57        INTERVALS 2
58        TRANSPARENT FALSE
59        STATUS ON
40    END60    END
83        END103        END
n84        PROJECTIONn
85            "init=epsg:4326"
86        END
87    END104    END
97            END114            END
n98        ENDn
99        PROJECTION
100            "init=epsg:4326"
101        END115        END
113        END127        END
n114        PROJECTIONn
115            "init=epsg:4326"
116        END
117    END128    END
128        END139        END
t129        PROJECTIONt
130            "init=epsg:4326"
131        END
132    END140    END

添加地图图例:示例

打开 MapServer 地图图例示例 New

下面展示的是使用表单进行提交,各种参数通过 input 来传递。效果与上面是一样的: