<div>I'm a newman in Mapserver. i want to use mapserver to distribute some products in my office such as shape file, modis geotiff,and so on. i study the tutorial create by Created by Pericles S. Nacionales . i think i grasp the idea in section one ,that mean i learn how to write my own mapfile. but i fail in section 2, when i try to imply mapfile into website. i don't understand how to manage template file.
</div>
<div> </div>
<div> </div>
<div>here is my mapfile</div>
<div> </div>
<div>
<p># The annotated map file (sort of)<br># Created by Pericles S. Nacionales for the MapServer tutorial<br># 20050408<br>#<br># MapServer map file uses the pound sign (#) to denote the start of a line<br># comment--each line that needs to be commented has to be prepended with a "#".
<br>#<br># Map files begin with MAP keyword to signify the start of the map object.<br># Well, the entire map file is THE map object. Enclosed between MAP and END<br># at the very bottom of this map file, are keyword/value pairs and other
<br># objects.<br>MAP<br> IMAGETYPE PNG<br> EXTENT 116.701621 38.555172 118.057785 40.251619<br> SIZE 800 600<br> SHAPEPATH "../data"<br> IMAGECOLOR 255 255 255<br> FONTSET "../fonts/fonts.list"
</p>
<p> # Layer objects are defined beneath the map object. You need at least one<br> # layer defined in your map file before you can display a map... You can<br> # define as many layers as you'd like although a limit is typically hard-coded
<br> # in map.h in the MapServer source. The default limit is set at 100. You'd<br> # have to have a very specialized application to need more than 100 layers in<br> # your application.</p>
<p> # Start of LAYER DEFINITIONS ---------------------------------------------<br> <br> <br> <br> LAYER # States polygon layer begins here<br> NAME county<br> DATA county<br> STATUS OFF
<br> TYPE POLYGON</p>
<p> # CLASSITEM defines the non-spatial attribute that you will be using to<br> # separate a layer into classes. This attribute will be in the DBF file<br> # of your shapefile (it will be different for each data format). In this
<br> # example the shapefile states_ugl has an associated database <br> # (states_ugl.dbf) that contains an attribute called "CLASS". You will be<br> # using two values in the CLASS attribute to separate the classes (also
<br> # called themes) used in this layer--land and water. CLASSITEM is used in <br> # association with the EXPRESSION parameter in the CLASS object. See below.<br> CLASSITEM "物非"</p>
<p> # Just like CLASSITEM, LABELITEM defines the database attribute that you <br> # will be using to draw labels. In this case, the values of the attribute <br> # "STATE" will be used to label the states polygons.
<br> LABELITEM "UNITENAME"</p>
<p> # The class object is defined within the layer object. You can define as<br> # many classes as you need (well, there are limits as with layers, but it's<br> # senseless to define more than ten on a "normal" layer. There are
<br> # situations, however, where you might have to do it.)<br> CLASS<br> NAME 'VERYGOOD'<br> EXPRESSION ([物非] >0.382)</p>
<p> # There are styles in a class, just like there are classes in a layer,<br> # just like there are layers in a map. You can define multiple styles in<br> # a class just as you can define multiple classes in a layer and multiple
<br> # layers in a map.<br> STYLE<br> COLOR 232 121 128<br> END<br> LABEL<br> COLOR 132 31 31<br> SHADOWCOLOR 218 218 218<br> SHADOWSIZE 2 2<br> TYPE TRUETYPE<br>
FONT simhei<br> SIZE 12<br> ANTIALIAS TRUE<br> POSITION AUTO<br> PARTIALS FALSE<br> MINDISTANCE 300<br> BUFFER 4<br> ENCODING GB2312<br> END # end of label</p>
<p> # There can be labels in a class, just like there are classes in a layer,<br> # just like there are layers in a map. You can define multiple labels in<br> # a class just as you can define multiple classes in a layer and multiple
<br> # layers in a map.<br> # MapServer has a very flexible labeling system. With that flexibility<br> # comes complexity, specially when using truetype fonts. Please read <br> # through the LABEL section of the MapServer map file documentation at
<br> # <a href="http://ms.gis.umn.edu/docs/reference/mapfile">http://ms.gis.umn.edu/docs/reference/mapfile</a> for more information.<br> <br> END<br> CLASS<br> NAME 'GOOD'<br> EXPRESSION ([物非]>
0.289 and [物非] < 0.382 )<br> STYLE<br> COLOR 25 123 12<br> END<br> LABEL<br> COLOR 132 31 31<br> SHADOWCOLOR 218 218 218<br> SHADOWSIZE 2 2<br> TYPE TRUETYPE<br> FONT simhei
<br> SIZE 12<br> ANTIALIAS TRUE<br> POSITION AUTO<br> PARTIALS FALSE<br> MINDISTANCE 300<br> BUFFER 4<br> ENCODING GB2312<br> END # end of label<br> END <br> <br> CLASS
<br> NAME 'MIDDLE'<br> EXPRESSION ([物非]>0.251 and [物非] < 0.289 )<br> STYLE<br> COLOR 255 255 21 <br> END<br> LABEL<br> COLOR 132 31 31<br> SHADOWCOLOR 218 218 218<br>
SHADOWSIZE 2 2<br> TYPE TRUETYPE<br> FONT simhei<br> SIZE 12<br> ANTIALIAS TRUE<br> POSITION AUTO<br> PARTIALS FALSE<br> MINDISTANCE 300<br> BUFFER 4<br> ENCODING GB2312
<br> END # end of label<br> END</p>
<p> CLASS<br> NAME 'BAD'<br> EXPRESSION ([物非]>0.179 and [物非] < 0.251 )<br> STYLE<br> COLOR 21 255 243<br> END<br> LABEL<br> COLOR 132 31 31<br> SHADOWCOLOR 218 218 218
<br> SHADOWSIZE 2 2<br> TYPE TRUETYPE<br> FONT simhei<br> SIZE 12<br> ANTIALIAS TRUE<br> POSITION AUTO<br> PARTIALS FALSE<br> MINDISTANCE 300<br> BUFFER 4<br>
ENCODING GB2312<br> END # end of label<br> END</p>
<p> CLASS<br> NAME 'VERYBAD'<br> EXPRESSION ([物非]=0.178 )<br> STYLE<br> COLOR 255 12 243<br> END<br> LABEL<br> COLOR 132 31 31<br> SHADOWCOLOR 218 218 218<br> SHADOWSIZE 2 2
<br> TYPE TRUETYPE<br> FONT simhei<br> SIZE 12<br> ANTIALIAS TRUE<br> POSITION AUTO<br> PARTIALS FALSE<br> MINDISTANCE 300<br> BUFFER 4<br> ENCODING GB2312<br> END # end of label
</p>
<p> END<br> END</p>
<p> LAYER # MODIS raster layer begins here<br> NAME tianjin_modis<br> DATA "raster/tianjin.tif"<br> STATUS OFF<br> TYPE RASTER<br> PROCESSING "BANDS=1,2,1"
<br> #OFFSITE 71 74 65</p>
<p> #PROJECTION<br> # "init=epsg:4326"<br> #END<br> END # MODIS raster layer ends here </p>
<p>LAYER # RAIL LINE layer begins here<br> NAME rail<br> DATA rail<br> STATUS OFF<br> TYPE LINE</p>
<p> # Here's an example of the input projection definition.<br> # EPSG:4326 is code for geographic (latlong) projection<br> # using the WGS84 datum.<br> #<br> # PROJECTION objects within the LAYER object define the input
<br> # projection--this is the native projection of your data.<br> PROJECTION<br> "init=epsg:4326"<br> END</p>
<p> # CLASSITEM defines the non-spatial attribute that you will be using to<br> # separate a layer into classes. This attribute will be in the DBF file<br> # of your shapefile (it will be different for each data format). In this
<br> # example the shapefile states_ugl has an associated database <br> # (states_ugl.dbf) that contains an attribute called "CLASS". You will be<br> # using two values in the CLASS attribute to separate the classes (also
<br> # called themes) used in this layer--land and water. CLASSITEM is used in <br> # association with the EXPRESSION parameter in the CLASS object. See below.<br> #CLASSITEM "CLASS"</p>
<p> CLASS<br> STYLE<br> SYMBOL 0<br> COLOR 232 232 0<br> END<br> END<br> END # RAIL LINE layer ends here</p>
<p><br>LAYER # ROAD LINE layer begins here<br> NAME road<br> DATA road<br> STATUS OFF<br> TYPE LINE</p>
<p> # Here's an example of the input projection definition.<br> # EPSG:4326 is code for geographic (latlong) projection<br> # using the WGS84 datum.<br> #<br> # PROJECTION objects within the LAYER object define the input
<br> # projection--this is the native projection of your data.<br> PROJECTION<br> "init=epsg:4326"<br> END</p>
<p> # CLASSITEM defines the non-spatial attribute that you will be using to<br> # separate a layer into classes. This attribute will be in the DBF file<br> # of your shapefile (it will be different for each data format). In this
<br> # example the shapefile states_ugl has an associated database <br> # (states_ugl.dbf) that contains an attribute called "CLASS". You will be<br> # using two values in the CLASS attribute to separate the classes (also
<br> # called themes) used in this layer--land and water. CLASSITEM is used in <br> # association with the EXPRESSION parameter in the CLASS object. See below.<br> #CLASSITEM "CLASS"</p>
<p> CLASS<br> STYLE<br> SYMBOL 0<br> COLOR 232 90 232<br> END<br> END<br> END # ROAD LINE layer ends here</p>
<p><br>LAYER # RAIL LINE layer begins here<br> NAME water<br> DATA water<br> STATUS OFF<br> TYPE LINE</p>
<p> # Here's an example of the input projection definition.<br> # EPSG:4326 is code for geographic (latlong) projection<br> # using the WGS84 datum.<br> #<br> # PROJECTION objects within the LAYER object define the input
<br> # projection--this is the native projection of your data.<br> PROJECTION<br> "init=epsg:4326"<br> END</p>
<p> # CLASSITEM defines the non-spatial attribute that you will be using to<br> # separate a layer into classes. This attribute will be in the DBF file<br> # of your shapefile (it will be different for each data format). In this
<br> # example the shapefile states_ugl has an associated database <br> # (states_ugl.dbf) that contains an attribute called "CLASS". You will be<br> # using two values in the CLASS attribute to separate the classes (also
<br> # called themes) used in this layer--land and water. CLASSITEM is used in <br> # association with the EXPRESSION parameter in the CLASS object. See below.<br> #CLASSITEM "CLASS"</p>
<p> CLASS<br> STYLE<br> SYMBOL 0<br> COLOR 232 90 232<br> END<br> END<br> END # WATER LINE layer ends here</p>
<p> LAYER # States line layer begins here<br> NAME county_line#緩侃廣吭曝蛍寄弌亟<br> DATA COUNTY<br> STATUS OFF<br> TYPE line</p>
<p><br> CLASS<br> NAME "State Boundary"<br> STYLE<br> COLOR 32 32 32<br> END<br> END<br> <br> END # States line layer ends here<br> <br> # End of LAYER DEFINITIONS -------------------------------
</p>
<p>END # All map files must come to an end just as all other things must come to...<br></p>
<p><a href="http://localhost:8080/cgi-bin/mapserv.exe?map=/ms4w/apps/tutorial/htdocs/tianjin_test.map&layer=rail&layer=road&layer=county&layer=water&layer=county_line&mode=map">http://localhost:8080/cgi-bin/mapserv.exe?map=/ms4w/apps/tutorial/htdocs/tianjin_test.map&layer=rail&layer=road&layer=county&layer=water&layer=county_line&mode=map
</a></p>
<p> </p>
<p>it looks just like what i want..now i want to use this mapfile into a template,just like turorial doing . </p>
<p> </p>
<p>so i add some keword, in the map object before layer object. </p>
<p>TEMPLATEPATTERN 'tianjin_test.html'<br> WEB<br> TEMPLATE 'tianjin_test.html'<br> IMAGEPATH '/ms4w/tmp/ms_tmp/'<br> IMAGEURL '/ms_tmp/'<br> END # Every object in MapServer must have an END.;)
</p>
<p> #<br> # Start of legend<br> #<br> LEGEND<br> KEYSIZE 12 12<br> LABEL<br> TYPE BITMAP<br> SIZE MEDIUM<br> COLOR 0 0 89<br> END<br> STATUS ON<br> END</p>
<p>the template file is just like toturial </p>
<p> </p>
<p><html><br><head><br><title>MapServer Workshop</title><br><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><br><link type="text/css" rel="stylesheet" href="/tutorial/ms35.css" />
<br></head></p>
<p><body bgcolor="#FFFFFF" text="#000000"><br><table width="601" align="center"><br><tr><br> <td width="593"><br> <h3 align="center">Example
2.1: Zoom and Pan Controls</h3></p>
<p><!-- START OF MAPSERVER FORM --><br><form name="mapserv" method="GET" action="/cgi-bin/mapserv.exe"></p>
<p><!-- HIDDEN MAPSERVER CGI VARIABLES --><br> <input type="hidden" name="map" value="[map]"><br> <input type="hidden" name="imgext" value="[mapext]">
<br> <input type="hidden" name="imgxy" value="399.5 299.5"><br> <br><table width="400" border="0" align="center"><br> <tr> <br> <td>
<br> <table width="400" border="1"><br> <tr> <br> <td></p>
<p><!-- SPECIFY MAP MODE --><br> <div align="center">Map Mode:<br><br> <select name="mode"><br> <option value="browse">Browse</option><br> <option value="map">Map</option>
<br> </select><br> </div><br> </td><br> <td><br><!-- FORM SUBMIT BUTTON --><br> <div align="center"><br> <input type="submit" name="submit" value="Refresh">
<br> </div><br> </td><br> <td><br><!-- ZOOM/PAN CONTROLS --><br> <div align="center">Map Control: <br><br> <select name="zoom">
<br> <option value="4" [zoom_4_select]>Zoom In 4x</option><br> <option value="3" [zoom_3_select]>Zoom In 3x</option><br> <option value="2" [zoom_2_select]>Zoom In 2x</option>
<br> <option value="1" [zoom_1_select]>Recenter</option><br> <option value="-2" [zoom_-2_select]>Zoom Out 2x</option><br> <option value="-3" [zoom_-3_select]>Zoom Out 3x</option>
<br> <option value="-4" [zoom_-4_select]>Zoom Out 4x</option><br> </select><br> </div><br> </td><br> </tr><br> <tr><br>
<!-- DISPLAY THE MAPSERVER-CREATED MAP IMAGE --><br> <td colspan="3" align="center" valign="top"><br> <input type="image" name="img" src="[img]" width="800"
<br> height="600" border="0"><br> </td><br> </tr><br> </table><br> </td><br> </tr><br></table><br></form><br></td></tr><br></table>
<br></body><br></html></p>
<p>so when i open this webpage, it shows me a picture just like what i want</p>
<p><a href="http://localhost:8080/cgi-bin/mapserv.exe?map=/ms4w/apps/tutorial/htdocs/tianjin_template.map&layer=county&layer=rail&layer=county_line&zoom=0&mode=browse&root=/tutorial&program=/cgi-bin/mapserv.exe&map_web_template=tianjin_test.html">
http://localhost:8080/cgi-bin/mapserv.exe?map=/ms4w/apps/tutorial/htdocs/tianjin_template.map&layer=county&layer=rail&layer=county_line&zoom=0&mode=browse&root=/tutorial&program=/cgi-bin/mapserv.exe&map_web_template=tianjin_test.html
</a></p>
<p>but problem happens when i click . it should be zoom in or zoom out but when i click i found nothing anymore, the picture just diappear.</p>
<p> </p>
<p> </p>
<p>can anyone help me about it??</p>
<p><br> </p>
<p> </p>
<p> </p></div>
<div><br clear="all"><br>-- <br>**************************************<br>wangtie <br>TianJin Meteorological Bureau <br>TEL <br>FAX<br>**************************************
</div>