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

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


7    FONTSET "../fonts/fonts.list"7    FONTSET "../fonts/fonts.list"
n8    PROJECTIONn8    TEMPLATEPATTERN "tmpl-*"
9        "init=epsg:4326"9    SYMBOL
10        NAME "star"
11        TYPE VECTOR
12        FILLED TRUE
13        POINTS
14            0 0.375
15            0.35 0.375
16            0.5 0
17            0.65 0.375
18            1 0.375
19            0.75 0.625
20            0.875 1
21            0.5 0.75
22            0.125 1
23            0.25 0.625
24        END
10    END25    END
t11    TEMPLATEPATTERN "tmpl-*"t26    REFERENCE
27        IMAGE "../images/worldref.png"
28        SIZE 300 150
29        EXTENT -180 -90 180 90
30        STATUS ON
31        MINBOXSIZE 30
32        MAXBOXSIZE 150
33        COLOR 255 255 0
34        OUTLINECOLOR 255 50 50
35        MARKERSIZE 30
36        MARKER "star"
37    END
38    SCALEBAR
39        IMAGECOLOR 255 255 255
40        LABEL
41            COLOR 0 0 0
42            SIZE TINY
43        END
44        STYLE 1
45        SIZE 160 2
46        COLOR 0 0 0
47        UNITS KILOMETERS
48        INTERVALS 2
49        TRANSPARENT FALSE
50        STATUS ON
51    END
12    WEB52    WEB

添加地图比例尺:示例

打开 MapServer 地图比例尺示例 New

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