[OpenLayers-Users] Openlayers not displaying mapserver wms

simi cserumola at yahoo.co.uk
Sun Mar 7 11:53:49 EST 2010


Hi, i am newbie to openlayers and i am encountering a problem in displaying a
layer served from a mapserver wms. I have checked my mapfile for wms
getcapabilities and its generates the xml document indicating that it is ok.
The mapfile was generated from QGIS and then edited. I am able to view a wms
layer from my mapfile in QGIS and directly via mapserver CGI. However, i
fail in Openlayers. Here is the mapfile and the openlayers file contents
respectively,

The mapfile

# Map file created from QGIS project file C:/Documents and
Settings/Kentlafetse/Desktop/Adverts.qgs
# Edit this file to customize for your map interface
# (Created with PyQgis MapServer Export plugin)
MAP
  NAME "Adverts"
  # Map image size
  SIZE 400 400
  UNITS meters

  EXTENT 7265.775000 -2751868.817315 100851.225000 -2701372.182685
  
  PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
  END

  # Background color for the map canvas -- change as desired
  IMAGECOLOR 255 255 255
  IMAGEQUALITY 95
  IMAGETYPE agg

  OUTPUTFORMAT
    NAME agg
    DRIVER AGG/PNG
    IMAGEMODE RGB
  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
      'ows_title'           'Adverts'
      'ows_onlineresource' 
'http://localhost/cgi-bin/mapserv.exe?map=Adverts.map&'
      'ows_srs'             'EPSG:4326'
      'wms_feature_info_mime_type' "text/html" 

    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
    TEMPLATE 'foo.html'
  END

  LAYER
    NAME 'adverts_pnts'
    TYPE POINT
    DUMP true
    TEMPLATE 'foo.html'
    EXTENT 7265.775000 -2751868.817315 100851.225000 -2701372.182685
    CONNECTIONTYPE postgis
    CONNECTION "user='#####' password='*******' dbname='postgis' port='5432'
host='localhost'"
    DATA "the_geom FROM adverts_pnts"
	
    METADATA
      'ows_title' 'adverts_pnts'
      'wms_feature_info_mime_type' "text/html" 

    END
    
    STATUS DEFAULT
    TRANSPARENCY 100
    PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
    END
    CLASS
       NAME 'adverts_pnts' 
       STYLE
         SIZE 10 
         OUTLINECOLOR 0 0 0
         COLOR 255 255 255
       END
    END
  END

END


The Openlayers html file

<html>
<head><title>OpenLayers project</title>
<script src="http://localhost/OpenLayers.js"></script>
<script type="text/javascript">

function init() {
var map = new OpenLayers.Map('map');
var wms = new OpenLayers.Layer.WMS(
"adverts_pnts",
"http://localhost/cgi-bin/mapserv.exe?map=Adverts.map&",
{layers: "adverts_pnts"}
);

map.addLayers(wms);

map.zoomToMaxExtent();
}
</script>
</head>
<body onload=init();>
<h2>OpenLayers Example</h2>
<div id='map'></div>
</body>
</html>



please help. i have tried a number of modifications to both the mapfile and
the openlayers html file without sucess.


-- 
View this message in context: http://n2.nabble.com/Openlayers-not-displaying-mapserver-wms-tp4690994p4690994.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.



More information about the Users mailing list