[OpenLayers-Users] (Openlayers + Mapserver) not able to dispaly Raster image.

ptang83 at yahoo.com ptang83 at yahoo.com
Wed Apr 16 00:14:01 EDT 2008


Hi Chris

Thanks for your patient. I am still getting empty box in my browser. There is no image in the box so I could't even copy the image URL.

Here is what I did.
1. load a raster image to qgis and export to generate below mapfile.
2. use shp2img to verify the mapfile can display correct picture.
3. Base on the mapfile content, I set maxExtent, maxresulotion (6086744.000000 + 4278894)/800 = 12957), and EPSG:4326.
4. refresh webbrowser and get a empty box without any image.

Any suggestion is highly appreciated.




=============
simple openlayers call
==============
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
 //  <title>My Test MapServer Layer</title>
    <style type="text/css">
        #map {
            width: 800px;
            height: 800px;
            border: 1px solid black;
        }
    </style>

   // <script type="text/javascript" src="http://clients.multimap.com/API/maps/1.1/metacarta_04"></script>

    <script src="http://openlayers.org/api/OpenLayers.js"></script>
    <script type="text/javascript">
        <!--
        var map, layer;

        function init(){
            map = new OpenLayers.Map( 'map', {maxExtent: new OpenLayers.Bounds(-6086744.000000 -5878356.737659 4278894.138000 7580130.593659
), maxResolution: 12957, units: 'meters', projection: "EPSG:4326"} );
            layer = new OpenLayers.Layer.MapServer( "OpenLayers WMS", 
                    "http://localhost/cgi-bin/mapserv.exe", 
                  {map: 'C:/Program Files/ms4w/Apache/htdocs/usa3.map'} );

            map.addLayer(layer);
            map.zoomToMaxExtent();
        }
        // -->
    </script>
  </head>
  <body onload="init()">
    <div id="map"></div>
  </body>
</html>




============================
map file
============================

# Map file created from QGIS project file C:/Program Files/Quantum GIS/usa3.qgs
# Edit this file to customize for your map interface
MAP
  NAME usa3
  # Map image size
  SIZE 800 500
  UNITS meters

  EXTENT -6086744.000000 -5878356.737659 4278894.138000 7580130.593659
  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/'
    LOG  'c:\tmp\mapserver.log'
    # WMS server settings
    METADATA
      'wms_title'           'usa3'
      '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 'nitelti020l'
    TYPE RASTER
    DATA 'C:\oatdir\nitelti020l.tar\nitelti020l.tif'
    METADATA
      'wms_title' 'nitelti020l'
    END
    STATUS DEFAULT
    TRANSPARENCY 100
    PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
    END
  END

END


      ____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ



More information about the Users mailing list