MapServer交互操作:地图图例

如何添加地图图例


这里是对应文件:

01 MAP
02     NAME "EX2_"
03     IMAGETYPE "png24"
04     EXTENT 166221 -371954 1505849 632767
05     SIZE 400 300
06     SHAPEPATH "../data"
07     SYMBOLSET "../symbols/symbols35.sym"
08     FONTSET "../fonts/fonts.list"
09     TEMPLATEPATTERN "example2*"
10     WEB
11         TEMPLATE "to be replaced by map_web_template variable in section2.html"
12         IMAGEPATH "/oswebgis/ms_tmp/"
13         IMAGEURL "/ms_tmp/"
14         METADATA
15             "wms_title" "WMS Demo Server"
16             "wms_onlineresource" "http://192.168.4.211/cgi-bin/mapserv?map=/mstu/htdocs/example2.map&"
17             "wms_srs" "EPSG:4269 EPSG:4326"
18         END
19     END
20     PROJECTION
21         "init=epsg:2163"
22     END
23     LEGEND
24         KEYSIZE 12 12
25         LABEL
26             TYPE BITMAP
27             SIZE MEDIUM
28             COLOR 0 0 89
29         END
30         STATUS ON
31     END
32     REFERENCE
33         IMAGE "../images/ugl_ref1.png"
34         SIZE 155 105
35         EXTENT 201621.496941 -294488.285333 1425518.020722 498254.511514
36         STATUS ON
37         MINBOXSIZE 10
38         MAXBOXSIZE 150
39         COLOR -1 -1 -1
40         OUTLINECOLOR 128 0 0
41         MARKERSIZE 8
42         MARKER "star"
43     END
44     SCALEBAR
45         IMAGECOLOR 255 255 255
46         LABEL
47             COLOR 0 0 0
48             SIZE TINY
49         END
50         STYLE 1
51         SIZE 100 2
52         COLOR 0 0 0
53         UNITS MILES
54         INTERVALS 2
55         TRANSPARENT FALSE
56         STATUS ON
57     END
58     LAYER
59         NAME "states"
60         DATA "states_ugl"
61         STATUS DEFAULT
62         TYPE POLYGON
63         REQUIRES "![modis] OR ![modis_jpl]"
64         METADATA
65             "wms_title" "test2"
66         END
67         PROJECTION
68             "init=epsg:4326"
69         END
70         CLASSITEM "CLASS"
71         CLASS
72             EXPRESSION "land"
73             STYLE
74                 SYMBOL 0
75                 COLOR 232 232 232
76             END
77         END
78     END
79     LAYER
80         NAME "modis"
81         DATA "raster/mod09a12003161_ugl_ll_idxa.tif"
82         STATUS OFF
83         TYPE RASTER
84         OFFSITE 70 74 66
85         PROJECTION
86             "init=epsg:4326"
87         END
88     END
89     LAYER
90         NAME "modis_jpl"
91         TYPE RASTER
92         OFFSITE 0 0 0
93         STATUS OFF
94         CONNECTIONTYPE WMS
95         CONNECTION "http://wms.jpl.nasa.gov/wms.cgi?"
96         METADATA
97             "wms_srs" "EPSG:4326"
98             "wms_name" "daily_terra"
99             "wms_server_version" "1.1.1"
100             "wms_format" "image/jpeg"
101         END
102         PROJECTION
103             "init=epsg:4326"
104         END
105     END
106     LAYER
107         NAME "hydro"
108         TYPE POLYGON
109         STATUS OFF
110         DATA "hydrop_ugl"
111         PROJECTION
112             "init=epsg:4326"
113         END
114         CLASSITEM "FEATURE"
115         CLASS
116             NAME "Lakes"
117             EXPRESSION /(^B|^C|^L|^R)./
118             STYLE
119                 COLOR 72 64 254
120             END
121         END
122         CLASS
123             NAME "Rivers"
124             EXPRESSION "Stream"
125             STYLE
126                 COLOR 136 128 255
127             END
128         END
129         CLASS
130             NAME "Wetlands"
131             EXPRESSION "Swamp or Marsh"
132             STYLE
133                 COLOR 195 252 255
134                 OUTLINECOLOR 195 252 255
135                 SYMBOL "circle"
136                 SIZE 0
137             END
138         END
139     END
140     LAYER
141         NAME "cty_roads"
142         GROUP "roads"
143         TYPE LINE
144         STATUS OFF
145         DATA "roads_ugl"
146         MAXSCALE 750000
147         PROJECTION
148             "init=epsg:4326"
149         END
150         CLASSITEM "CLASS1"
151         CLASS
152             NAME "Minor Arterial Roads"
153             EXPRESSION "3"
154             STYLE
155                 COLOR 165 165 165
156             END
157         END
158         CLASS
159             EXPRESSION "4"
160             STYLE
161                 COLOR 210 210 210
162             END
163         END
164     END
165     LAYER
166         NAME "state_hwy"
167         GROUP "roads"
168         MAXSCALE 1500000
169         STATUS OFF
170         DATA "roads_ugl"
171         TYPE LINE
172         FILTERITEM "CLASS1"
173         FILTER "2"
174         CLASS
175             NAME "Principal Arterial Roads"
176             STYLE
177                 COLOR 255 0 0
178                 SIZE 1
179                 SYMBOL "circle"
180             END
181         END
182         PROJECTION
183             "init=epsg:4326"
184         END
185     END
186     LAYER
187         NAME "interstate"
188         GROUP "roads"
189         STATUS OFF
190         DATA "roads_ugl"
191         TYPE LINE
192         FILTERITEM "CLASS1"
193         FILTER "1"
194         CLASS
195             NAME "Interstate Hwy."
196             STYLE
197                 COLOR 128 0 0
198             END
199         END
200         PROJECTION
201             "init=epsg:4326"
202         END
203     END
204     LAYER
205         NAME "states"
206         DATA "states_ugl"
207         STATUS OFF
208         TYPE LINE
209         PROJECTION
210             "init=epsg:4326"
211         END
212         CLASSITEM "CLASS"
213         CLASS
214             NAME "State Boundary"
215             EXPRESSION "land"
216             STYLE
217                 SYMBOL "line5"
218                 COLOR 32 32 32
219                 SIZE 1
220             END
221         END
222     END
223     LAYER
224         NAME "roads_anno"
225         GROUP "roads"
226         MAXSCALE 750000
227         STATUS OFF
228         DATA "roads_ugl"
229         TYPE LINE
230         LABELITEM "SIGN"
231         CLASSITEM "CLASS1"
232         CLASS
233             EXPRESSION "3"
234             STYLE
235                 COLOR 0 0 0
236                 SYMBOL "../symbols/sthwy.png"
237             END
238             LABEL
239                 MINFEATURESIZE 50
240                 MINDISTANCE 150
241                 POSITION CC
242                 SIZE TINY
243                 COLOR 0 0 0
244             END
245         END
246         CLASS
247             EXPRESSION "2"
248             STYLE
249                 COLOR 0 0 0
250                 SYMBOL "../symbols/ushwy.png"
251             END
252             LABEL
253                 MINFEATURESIZE 50
254                 MINDISTANCE 150
255                 POSITION CC
256                 SIZE TINY
257                 COLOR 0 0 0
258             END
259         END
260         PROJECTION
261             "init=epsg:4326"
262         END
263     END
264     LAYER
265         NAME "roads_anno1"
266         GROUP "roads"
267         STATUS OFF
268         DATA "roads_ugl"
269         TYPE LINE
270         LABELITEM "SIGN"
271         CLASSITEM "CLASS1"
272         CLASS
273             EXPRESSION "1"
274             STYLE
275                 COLOR 0 0 0
276                 SYMBOL "../../symbols/interstate.png"
277             END
278             LABEL
279                 MINFEATURESIZE 20
280                 MINDISTANCE 150
281                 POSITION CC
282                 SIZE TINY
283                 COLOR 255 255 255
284             END
285         END
286         PROJECTION
287             "init=epsg:4326"
288         END
289     END
290     LAYER
291         NAME "states"
292         DATA "states_ugl"
293         STATUS OFF
294         TYPE POLYGON
295         PROJECTION
296             "init=epsg:4326"
297         END
298         CLASSITEM "CLASS"
299         LABELITEM "STATE"
300         CLASS
301             EXPRESSION "land"
302             STYLE
303                 COLOR -1 -1 -1
304             END
305             LABEL
306                 COLOR 132 31 31
307                 OUTLINECOLOR 128 128 128
308                 SHADOWCOLOR 218 218 218
309                 SHADOWSIZE 1 1
310                 TYPE TRUETYPE
311                 FONT "arial-bold"
312                 SIZE 12
313                 ANTIALIAS TRUE
314                 POSITION CL
315                 PARTIALS FALSE
316                 MINDISTANCE 200
317                 BUFFER 4
318             END
319         END
320     END
321 END

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

添加地图图例:示例

打开 MapServer 地图图例示例

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

Proceed to: