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.


here is my mapfile


# The annotated map file (sort of)
# Created by Pericles S. Nacionales for the MapServer tutorial
# 20050408
#
# MapServer map file uses the pound sign (#) to denote the start of a line
# comment--each line that needs to be commented has to be prepended with a
"#".
#
# Map files begin with MAP keyword to signify the start of the map object.
# Well, the entire map file is THE map object.  Enclosed between MAP and END
# at the very bottom of this map file, are keyword/value pairs and other
# objects.
MAP
 IMAGETYPE      PNG
 EXTENT         116.701621 38.555172 118.057785 40.251619
 SIZE           800 600
 SHAPEPATH      "../data"
 IMAGECOLOR     255 255 255
 FONTSET        "../fonts/fonts.list"

 # Layer objects are defined beneath the map object.  You need at least one
 # layer defined in your map file before you can display a map...  You can
 # define as many layers as you'd like although a limit is typically
hard-coded
 # in map.h in the MapServer source.  The default limit is set at 100.
You'd
 # have to have a very specialized application to need more than 100 layers
in
 # your application.

 # Start of LAYER DEFINITIONS ---------------------------------------------



 LAYER # States polygon layer begins here
   NAME         county
   DATA         county
   STATUS       OFF
   TYPE         POLYGON

   # CLASSITEM defines the non-spatial attribute that you will be using to
   # separate a layer into classes.  This attribute will be in the DBF file
   # of your shapefile (it will be different for each data format).  In
this
   # example the shapefile states_ugl has an associated database
   # (states_ugl.dbf) that contains an attribute called "CLASS".  You will
be
   # using two values in the CLASS attribute to separate the classes (also
   # called themes) used in this layer--land and water.  CLASSITEM is used
in
   # association with the EXPRESSION parameter in the CLASS object.  See
below.
   CLASSITEM    "湿润"

   # Just like CLASSITEM, LABELITEM defines the database attribute that you

   # will be using to draw labels.  In this case, the values of the
attribute
   # "STATE" will be used to label the states polygons.
   LABELITEM    "UNITENAME"

   # The class object is defined within the layer object.  You can define
as
   # many classes as you need (well, there are limits as with layers, but
it's
   # senseless to define more than ten on a "normal" layer.  There are
   # situations, however, where you might have to do it.)
   CLASS
     NAME 'VERYGOOD'
     EXPRESSION ([湿润] >0.382)

     # There are styles in a class, just like there are classes in a layer,
     # just like there are layers in a map.  You can define multiple styles
in
     # a class just as you can define multiple classes in a layer and
multiple
     # layers in a map.
     STYLE
       COLOR      232 121 128
     END
      LABEL
       COLOR 132 31 31
       SHADOWCOLOR 218 218 218
       SHADOWSIZE 2 2
       TYPE TRUETYPE
       FONT simhei
       SIZE 12
       ANTIALIAS TRUE
       POSITION AUTO
       PARTIALS FALSE
       MINDISTANCE 300
       BUFFER 4
ENCODING GB2312
     END # end of label

     # There can be labels in a class, just like there are classes in a
layer,
     # just like there are layers in a map.  You can define multiple labels
in
     # a class just as you can define multiple classes in a layer and
multiple
     # layers in a map.
     # MapServer has a very flexible labeling system.  With that
flexibility
     # comes complexity, specially when using truetype fonts.  Please read
     # through the LABEL section of the MapServer map file documentation at
     # http://ms.gis.umn.edu/docs/reference/mapfile for more information.

   END
   CLASS
     NAME 'GOOD'
     EXPRESSION ([湿润]>0.289 and [湿润] < 0.382 )
     STYLE
COLOR    25 123 12
     END
      LABEL
       COLOR  132 31 31
       SHADOWCOLOR 218 218 218
       SHADOWSIZE 2 2
       TYPE TRUETYPE
       FONT simhei
       SIZE 12
       ANTIALIAS TRUE
       POSITION AUTO
       PARTIALS FALSE
       MINDISTANCE 300
       BUFFER 4
ENCODING GB2312
     END # end of label
   END

   CLASS
     NAME 'MIDDLE'
     EXPRESSION ([湿润]>0.251 and [湿润] < 0.289 )
     STYLE
COLOR    255 255 21
     END
      LABEL
       COLOR  132 31 31
       SHADOWCOLOR 218 218 218
       SHADOWSIZE 2 2
       TYPE TRUETYPE
       FONT simhei
       SIZE 12
       ANTIALIAS TRUE
       POSITION AUTO
       PARTIALS FALSE
       MINDISTANCE 300
       BUFFER 4
ENCODING GB2312
     END # end of label
   END

   CLASS
     NAME 'BAD'
     EXPRESSION ([湿润]>0.179 and [湿润] < 0.251 )
     STYLE
COLOR    21 255 243
     END
      LABEL
       COLOR 132 31 31
       SHADOWCOLOR 218 218 218
       SHADOWSIZE 2 2
       TYPE TRUETYPE
       FONT simhei
       SIZE 12
       ANTIALIAS TRUE
       POSITION AUTO
       PARTIALS FALSE
       MINDISTANCE 300
       BUFFER 4
ENCODING GB2312
     END # end of label
   END

   CLASS
     NAME 'VERYBAD'
     EXPRESSION ([湿润]=0.178 )
     STYLE
COLOR    255 12 243
     END
     LABEL
       COLOR 132 31 31
       SHADOWCOLOR 218 218 218
       SHADOWSIZE 2 2
       TYPE TRUETYPE
       FONT simhei
       SIZE 12
       ANTIALIAS TRUE
       POSITION AUTO
       PARTIALS FALSE
       MINDISTANCE 300
       BUFFER 4
ENCODING GB2312
     END # end of label

   END
   END

 LAYER # MODIS raster layer begins here
   NAME         tianjin_modis
   DATA         "raster/tianjin.tif"
   STATUS       OFF
   TYPE         RASTER
   PROCESSING   "BANDS=1,2,1"
   #OFFSITE      71 74 65

   #PROJECTION
   #  "init=epsg:4326"
   #END
 END # MODIS raster layer ends here

LAYER # RAIL LINE layer begins here
   NAME         rail
   DATA         rail
   STATUS       OFF
   TYPE         LINE

   # Here's an example of the input projection definition.
   # EPSG:4326 is code for geographic (latlong) projection
   # using the WGS84 datum.
   #
   # PROJECTION objects within the LAYER object define the input
   # projection--this is the native projection of your data.
   PROJECTION
     "init=epsg:4326"
   END

   # CLASSITEM defines the non-spatial attribute that you will be using to
   # separate a layer into classes.  This attribute will be in the DBF file
   # of your shapefile (it will be different for each data format).  In
this
   # example the shapefile states_ugl has an associated database
   # (states_ugl.dbf) that contains an attribute called "CLASS".  You will
be
   # using two values in the CLASS attribute to separate the classes (also
   # called themes) used in this layer--land and water.  CLASSITEM is used
in
   # association with the EXPRESSION parameter in the CLASS object.  See
below.
   #CLASSITEM    "CLASS"

   CLASS
     STYLE
       SYMBOL     0
       COLOR      232 232 0
     END
   END
 END # RAIL LINE  layer ends here


LAYER # ROAD LINE layer begins here
   NAME         road
   DATA         road
   STATUS       OFF
   TYPE         LINE

   # Here's an example of the input projection definition.
   # EPSG:4326 is code for geographic (latlong) projection
   # using the WGS84 datum.
   #
   # PROJECTION objects within the LAYER object define the input
   # projection--this is the native projection of your data.
   PROJECTION
     "init=epsg:4326"
   END

   # CLASSITEM defines the non-spatial attribute that you will be using to
   # separate a layer into classes.  This attribute will be in the DBF file
   # of your shapefile (it will be different for each data format).  In
this
   # example the shapefile states_ugl has an associated database
   # (states_ugl.dbf) that contains an attribute called "CLASS".  You will
be
   # using two values in the CLASS attribute to separate the classes (also
   # called themes) used in this layer--land and water.  CLASSITEM is used
in
   # association with the EXPRESSION parameter in the CLASS object.  See
below.
   #CLASSITEM    "CLASS"

   CLASS
     STYLE
       SYMBOL     0
       COLOR      232 90 232
     END
   END
 END # ROAD LINE  layer ends here


LAYER # RAIL LINE layer begins here
   NAME         water
   DATA         water
   STATUS       OFF
   TYPE         LINE

   # Here's an example of the input projection definition.
   # EPSG:4326 is code for geographic (latlong) projection
   # using the WGS84 datum.
   #
   # PROJECTION objects within the LAYER object define the input
   # projection--this is the native projection of your data.
   PROJECTION
     "init=epsg:4326"
   END

   # CLASSITEM defines the non-spatial attribute that you will be using to
   # separate a layer into classes.  This attribute will be in the DBF file
   # of your shapefile (it will be different for each data format).  In
this
   # example the shapefile states_ugl has an associated database
   # (states_ugl.dbf) that contains an attribute called "CLASS".  You will
be
   # using two values in the CLASS attribute to separate the classes (also
   # called themes) used in this layer--land and water.  CLASSITEM is used
in
   # association with the EXPRESSION parameter in the CLASS object.  See
below.
   #CLASSITEM    "CLASS"

   CLASS
     STYLE
       SYMBOL     0
       COLOR       232 90 232
     END
   END
 END # WATER LINE  layer ends here

 LAYER # States line layer begins here
   NAME         county_line#此处注意区分大小写
   DATA         COUNTY
   STATUS       OFF
   TYPE         line


   CLASS
     NAME       "State Boundary"
     STYLE
       COLOR    32 32 32
     END
   END

 END # States line layer ends here

 # End of LAYER DEFINITIONS -------------------------------

END # All map files must come to an end just as all other things must come
to...

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



it looks just like what i want..now i want to use this mapfile into a
template,just like turorial doing .



so i add some keword, in the map object  before layer object.

TEMPLATEPATTERN 'tianjin_test.html'
 WEB
   TEMPLATE  'tianjin_test.html'
   IMAGEPATH '/ms4w/tmp/ms_tmp/'
   IMAGEURL  '/ms_tmp/'
 END # Every object in MapServer must have an END.;)

 #
 # Start of legend
 #
 LEGEND
   KEYSIZE 12 12
   LABEL
     TYPE BITMAP
     SIZE MEDIUM
     COLOR 0 0 89
   END
   STATUS ON
 END

the template file is just like toturial



<html>
<head>
<title>MapServer Workshop</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link type="text/css" rel="stylesheet" href="/tutorial/ms35.css" />
</head>

<body bgcolor="#FFFFFF" text="#000000">
<table width="601" align="center">
<tr>
   <td width="593">
<h3 align="center">Example 2.1: Zoom and Pan Controls</h3>

<!-- START OF MAPSERVER FORM -->
<form name="mapserv" method="GET" action="/cgi-bin/mapserv.exe">

<!-- HIDDEN MAPSERVER CGI VARIABLES -->
   <input type="hidden" name="map" value="[map]">
   <input type="hidden" name="imgext" value="[mapext]">
   <input type="hidden" name="imgxy" value="399.5 299.5">

<table width="400" border="0" align="center">
 <tr>
   <td>
<table width="400" border="1">
  <tr>
    <td>

<!-- SPECIFY MAP MODE -->
      <div align="center">Map Mode:<br>
 <select name="mode">
   <option value="browse">Browse</option>
   <option value="map">Map</option>
 </select>
      </div>
    </td>
    <td>
<!-- FORM SUBMIT BUTTON -->
      <div align="center">
 <input type="submit" name="submit" value="Refresh">
      </div>
    </td>
    <td>
<!-- ZOOM/PAN CONTROLS -->
      <div align="center">Map Control: <br>
               <select name="zoom">
                 <option value="4" [zoom_4_select]>Zoom In 4x</option>
                 <option value="3" [zoom_3_select]>Zoom In 3x</option>
                 <option value="2" [zoom_2_select]>Zoom In 2x</option>
                 <option value="1" [zoom_1_select]>Recenter</option>
                 <option value="-2" [zoom_-2_select]>Zoom Out 2x</option>
                 <option value="-3" [zoom_-3_select]>Zoom Out 3x</option>
                 <option value="-4" [zoom_-4_select]>Zoom Out 4x</option>
               </select>
             </div>
    </td>
  </tr>
  <tr>
<!-- DISPLAY THE MAPSERVER-CREATED MAP IMAGE -->
    <td colspan="3" align="center" valign="top">
      <input type="image" name="img" src="[img]" width="800"
       height="600" border="0">
    </td>
  </tr>
</table>
   </td>
 </tr>
</table>
</form>
</td></tr>
</table>
</body>
</html>

so when i open this webpage, it shows me a picture just like what i want

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

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.





can anyone help me about it??









--
**************************************
wangtie
TianJin Meteorological Bureau
TEL
FAX
**************************************

Reply via email to