[OpenLayers-Users] Display maps in OL from mapserver

Chen kuja eiclkun at gmail.com
Tue May 6 02:31:35 EDT 2008


hi all,
it's been two days, now i have to admit i am not gifted in any kind of
programming at all. I stuck at the first step of using OL. after surfing the
maillists and the  FAQ for hours, still, i can't display my map..

first of all, i can see the map from mapserver, like

http://127.1/cgi-bin/mapserv.exe?mode=map&map=/ms4w/apps/map.map

 i downloaded the lite.html from the tutorial and than export it to the
firefox.  unfortunately, although i can find  openlayer's control box, but
the rest are just two pink image icons.

this is the image icon's link

http://127.1/cgi-bin/mapserv.exe?layers=Shp_Lakes&map=map%3D%2Fms4w%2Fapps%2Fmap.map&mode=map&map_imagetype=png&mapext=0+-90+180+90&imgext=0+-90+180+90&map_size=256+256&imgx=128&imgy=128&imgxy=256+256

besides, my .shp files are in wgs84 format, so i thought the projection
should be right.

the html code shows below,
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <style type="text/css">
        #map {
            width: 800px;
            height: 475px;
            border: 1px solid black;
        }
    </style>
    <script src="http://openlayers.org/dev/lib/OpenLayers.js"></script>
    <script type="text/javascript">
        <!--
        var map, layer;

        function init(){
            map = new OpenLayers.Map( 'map' );
            layer = new OpenLayers.Layer.MapServer( "OpenLayers WMS",
                    "http://127.1/cgi-bin/mapserv.exe?", { layers:
'Shp_Lakes',
 map: 'map=/ms4w/apps/map.map'} );
            map.addLayer(layer);
            map.zoomToMaxExtent();
        }
        // -->
    </script>
  </head>
  <body onload="init()">
    <div id="map"></div>
  </body>
</html>

and the mapfile (generated by qgis)
# Map file created from QGIS project file C:/digital/map.qgs
# Edit this file to customize for your map interface
MAP
  NAME hzau
  # Map image size
  SIZE 2000 2000
  UNITS ?

  EXTENT 114.327181 30.454108 114.363140 30.495525
  PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
  END

  # Background color for the map canvas -- change as desired
  IMAGECOLOR 192 192 192
  IMAGEQUALITY 95
  IMAGETYPE png
  OUTPUTFORMAT
    NAME png
    DRIVER 'GD/PNG'
    MIMETYPE 'image/png'
    #IMAGEMODE PC256
    EXTENSION 'png'
  END
  # Legend
  LEGEND
      IMAGECOLOR 255 255 255
    STATUS ON
    KEYSIZE 18 12
    LABEL
      TYPE BITMAP
      SIZE MEDIUM
      COLOR 0 0 89
    END
  END

  # Web interface definition. Only the template parameter
  # is required to display a map. See MapServer documentation
  WEB
    # Set IMAGEPATH to the path where MapServer should
    # write its output.
    IMAGEPATH '/tmp/'

    # Set IMAGEURL to the url that points to IMAGEPATH
    # as defined in your web server configuration
    IMAGEURL '/tmp/'

    # WMS server settings
    METADATA
      'wms_title'           'hzau'
      'wms_onlineresource'  'http://my.host.com/cgi-bin/mapserv?map=wms.map&
'
      'wms_srs'             'EPSG:4326'
    END

    #Scale range at which web interface will operate
    # Template and header/footer settings
    # Only the template parameter is required to display a map. See
MapServer documentation
  END

  LAYER
    NAME 'Shp_Background'
    TYPE POLYGON
    DATA 'C:\digital\Shp_Background.shp'
    METADATA
      'wms_title' 'Shp_Background'
    END
    STATUS DEFAULT
    TRANSPARENCY 100
    PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
    END
    CLASS
       NAME 'Shp_Background'
       STYLE
         SYMBOL 0
         SIZE 6
         OUTLINECOLOR 0 0 0
         COLOR 236 230 220
       END
    END
  END

  LAYER
    NAME 'Shp_Buildings'
    TYPE POLYGON
    DATA 'C:\digital\Shp_Buildings.shp'
    METADATA
      'wms_title' 'Shp_Buildings'
    END
    STATUS DEFAULT
    TRANSPARENCY 100
    PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
    END
    CLASS
       NAME 'Shp_Buildings'
       STYLE
         SYMBOL 0
         SIZE 6
         OUTLINECOLOR 0 0 0
         COLOR 255 255 255
       END
    END
  END

  LAYER
    NAME 'Shp_Fields'
    TYPE POLYGON
    DATA 'C:\digital\Shp_Fields.shp'
    METADATA
      'wms_title' 'Shp_Fields'
    END
    STATUS DEFAULT
    TRANSPARENCY 100
    PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
    END
    CLASS
       NAME 'Shp_Fields'
       STYLE
         SYMBOL 0
         SIZE 6
         OUTLINECOLOR 0 0 0
         COLOR 190 203 144
       END
    END
  END

  LAYER
    NAME 'Shp_Lakes'
    TYPE POLYGON
    DATA 'C:\digital\Shp_Lakes.shp'
    METADATA
      'wms_title' 'Shp_Lakes'
    END
    STATUS DEFAULT
    TRANSPARENCY 100
    PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
    END
    CLASS
       NAME 'Shp_Lakes'
       STYLE
         SYMBOL 0
         SIZE 6
         OUTLINECOLOR 0 0 0
         COLOR 152 178 203
       END
    END
  END

  LAYER
    NAME 'Shp_Landscapes'
    TYPE POLYGON
    DATA 'C:\digital\Shp_Landscapes.shp'
    METADATA
      'wms_title' 'Shp_Landscapes'
    END
    STATUS DEFAULT
    TRANSPARENCY 100
    PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
    END
    CLASS
       NAME 'Shp_Landscapes'
       STYLE
         SYMBOL 0
         SIZE 6
         OUTLINECOLOR 0 0 0
         COLOR 166 203 148
       END
    END
  END

  LAYER
    NAME 'Shp_Playground'
    TYPE POLYGON
    DATA 'C:\digital\Shp_Playground.shp'
    METADATA
      'wms_title' 'Shp_Playground'
    END
    STATUS DEFAULT
    TRANSPARENCY 100
    PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
    END
    CLASS
       NAME 'Shp_Playground'
       STYLE
         SYMBOL 0
         SIZE 6
         OUTLINECOLOR 0 0 0
         COLOR 254 253 214
       END
    END
  END

  LAYER
    NAME 'Shp_Public_Facilities'
    TYPE POINT
    DATA 'C:\digital\Shp_Public_Facilities.shp'
    METADATA
      'wms_title' 'Shp_Public_Facilities'
    END
    STATUS DEFAULT
    TRANSPARENCY 100
    PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
    END
    CLASS
       NAME 'Shp_Public_Facilities'
       STYLE
         SYMBOL 'CIRCLE'
         SIZE 6
         OUTLINECOLOR 0 0 0
         COLOR 101 68 76
       END
    END
  END

  LAYER
    NAME 'Shp_Roads'
    TYPE LINE
    DATA 'C:\digital\Shp_Roads.shp'
    METADATA
      'wms_title' 'Shp_Roads'
    END
    STATUS DEFAULT
    TRANSPARENCY 85
    PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
    END
    CLASS
       NAME 'Shp_Roads'
       STYLE
         SYMBOL 0
         SIZE 6
         OUTLINECOLOR 255 255 255
         COLOR 0 0 0
       END
    END
  END

  LAYER
    NAME 'Shp_Roads'
    TYPE LINE
    DATA 'C:\digital\Shp_Roads.shp'
    METADATA
      'wms_title' 'Shp_Roads'
    END
    STATUS DEFAULT
    TRANSPARENCY 28
    PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
    END
    CLASS
       NAME 'Shp_Roads'
       STYLE
         SYMBOL 0
         SIZE 6
         OUTLINECOLOR 17 22 7
         COLOR 0 0 0
       END
    END
  END

  LAYER
    NAME 'shp_fishpond'
    TYPE POLYGON
    DATA 'C:\digital\shp_fishpond.shp'
    METADATA
      'wms_title' 'shp_fishpond'
    END
    STATUS DEFAULT
    TRANSPARENCY 100
    PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
    END
    CLASS
       NAME 'shp_fishpond'
       STYLE
         SYMBOL 0
         SIZE 6
         OUTLINECOLOR 0 0 0
         COLOR 204 224 225
       END
    END
  END


      #Circle symbol
      SYMBOL
        NAME 'CIRCLE'
        TYPE ellipse
        FILLED true
        POINTS
          1 1
        END
      END
END

cuz i am totally new to programming, so any  information  or help  would be
appreciated.  Tks in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20080506/c5c783da/attachment.html


More information about the Users mailing list