[OpenLayers-Users] Easy question about adding a map file as a WMS
layer from a beginner
Дмитрий Кожух
kozhukh at tut.by
Sat Sep 10 07:41:11 EDT 2011
Hello!
I've just started to learn about OpenLayers, MapServer etc.
And I have a question. When I add a Map file as Mapserver layer it works
fine, but when I add it as WMS layer it just displays a background color
(that I have defined in my .map file) and some small unreadable letters.
Probably you would be so kind to help me to find a mistake in my map file or
in html?
Thanks and sorry for asking such a beginner question.
Here is my mapfile:
MAP
NAME 'World Map'
# Map image size
STATUS ON
SIZE 600 300
EXTENT -180.0 -90.0 180.0 90.0
UNITS dd
SHAPEPATH 'C://GIS/Data/puvWorld'
IMAGECOLOR 255 255 255
PROJECTION
'proj=longlat'
'ellps=WGS84'
'datum=WGS84'
'no_defs'
END
# Background color for the map canvas -- change as desired
IMAGECOLOR 255 0 0
IMAGEQUALITY 95
IMAGETYPE png24
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' 'World Map'
'wms_onlineresource' '
http://localhost/cgi-bin/mapserv.exe?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 'world_raster'
TYPE RASTER
DATA world_raster.tif
METADATA
'wms_title' 'world_raster'
#'queryable' 'true'
#'wms_srs' 'EPSG:4326'
END
STATUS DEFAULT
TRANSPARENCY 100
PROJECTION
'proj=longlat'
'ellps=WGS84'
'datum=WGS84'
'no_defs'
END
END
LAYER
NAME 'world_adm0'
TYPE POLYGON
DATA world_adm0
METADATA
'wms_title' 'world_adm0'
#'queryable' 'true'
#'wms_srs' 'EPSG:4326'
END
STATUS DEFAULT
TRANSPARENCY 100
PROJECTION
'proj=longlat'
'ellps=WGS84'
'datum=WGS84'
'no_defs'
END
CLASS
NAME 'world_adm0'
STYLE
SYMBOL 0
SIZE 6
OUTLINECOLOR 0 0 0
END
END
END
END
And here is my html code:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
#map {
width: 600px;
height: 300px;
border: 1px solid black;
}
</style>
<script src="/openlayers/OpenLayers.js"></script>
<script type="text/javascript">
<!--
var map, layer;
function init(){
map = new OpenLayers.Map( 'map' );
layer = new
OpenLayers.Layer.WMS( "World Map",
"
http://127.0.0.1/cgi-bin/mapserv.exe?map=C:/GIS/Projects/puvWorld.map"
/*{
layers: 'world_raster',
'world_adm0',
srs: 'EPSG:4326'
}*/
);
/*layer = new
OpenLayers.Layer.MapServer( "World Map",
"http://localhost/cgi-bin/mapserv.exe", {map:
'C:/GIS/Projects/puvWorld.map'} );*/
/*layer = new OpenLayers.Layer.MapServer( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic'}
);*/
map.addLayer(layer);
map.zoomToMaxExtent();
}
// -->
</script>
</head>
<body onLoad="init()">
<div id="map"></div>
</body>
</html>
Thank you very much in advance.
Zmicjer Kožuch
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20110910/16430c75/attachment-0001.html
More information about the Users
mailing list