直接访问本机的MapServer服务器可以正确看到地图,
但,使用OpenLayer写个简单的页面却看不到地图,请指教哇。
用IE直接访问MapServer可以显示地图:
http://127.0.0.1/cgi-bin/mapserv.exe?MAP=C:/OSGeo4W/apache/htdocs/SZMAP/sz.map&LAYERS=ALL&MODE=MAP
通过OpenLayer的网页访问无法显示地图:
http://127.0.0.1/szmap/openlayerTT.html
openlayerTT.html如下:
<!DOCTYPE html>
<html>
<head>
<title>OpenLayers Tutorial - Basic Map Setup</title>
<script src="http://openlayers.org/api/OpenLayers.js"></script>
<script type="text/javascript">
var map, baseLayer;
function init(){
map = new OpenLayers.Map("map");
layer = new OpenLayers.Layer.MapServer( "region",
"http://127.0.0.1/cgi-bin/mapserv.exe",
{map: 'C:/OSGeo4W/apache/htdocs/SZMAP/sz.map'});
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(114,22));
}
</script>
<style>
@media screen
{
#map{width: 500px; height:250px; border: 2px solid black;}
}
</style>
</head>
<body onload="init()">
<h3>OpenLayers Tutorial - Basic Map Setup</h3>
<div id="map"></div>
</body>
</html>
sz.map 内容如下:
# Map file created from QGIS project file
# Edit this file to customize for your map interface
# (Created with PyQgis MapServer Export plugin)
MAP
NAME "QGIS-MAP"
# Map image size
SIZE 600 400
UNITS dd
EXTENT 114.055799 22.537858 114.108519 22.561268
FONTSET './fonts/fonts.txt'
SYMBOLSET './symbols/symbols.txt'
PROJECTION
'proj=longlat'
'datum=WGS84'
'no_defs'
END