MapServer interaction: add reference map

Refrence map concept

The reference map is a basic function of GIS. The reference map, as the name implies, can view the position of the map displayed in the map frame in the entire map on the reference map as if viewed from the sky. Refrence map is one of the essential functions of GIS software. It is mainly used to indicate the geographical extent of the data view in the whole map.

The general function of the reference map:

  1. The reference map view is synchronized with the geographic extent of the data view.
  2. The current extent of the data view can be marked with a rectangular box in the reference map view. If the display range of the data view changes, the position of the rectangle in the reference map view will also change.
  3. Operating the view in the reference map, the geographic extent in the data view will also be adjusted synchronously. When the mouse eye clicks with the mouse, the data view can be moved to the clicked position. Drag the rectangle to adjust the extent of the map in the data view; when you drag the rectangle over the reference map view, the data view can display the contents of the rectangle in full view.

How add reference map

Here is the corresponding file:

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

You can see the HTML Template code here.

7    FONTSET "../fonts/fonts.list"7    FONTSET "../fonts/fonts.list"
nn8    PROJECTION
9        "init=epsg:4326"
10    END
8    TEMPLATEPATTERN "tmpl-*"11    TEMPLATEPATTERN "tmpl-*"
36        MARKER "star"39        MARKER "star"
n37    ENDn
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    END40    END
94        END83        END
nn84        PROJECTION
85            "init=epsg:4326"
86        END
95    END87    END
105            END97            END
nn98        END
99        PROJECTION
100            "init=epsg:4326"
106        END101        END
118        END113        END
nn114        PROJECTION
115            "init=epsg:4326"
116        END
119    END117    END
130        END128        END
tt129        PROJECTION
130            "init=epsg:4326"
131        END
131    END132    END

Refrence map in MapServer

Open MapServer Refrence map

The following shows a form submission, and various parameters are passed through input. The effect is the same as above: