.map文件为
MAP
EXTENT 70 5 140 55
IMAGETYPE png
SIZE 1000 800
OUTPUTFORMAT
NAME "png"
MIMETYPE "image/png"
DRIVER "GD/PNG"
EXTENSION "png"
IMAGEMODE "PC256"
TRANSPARENT TRUE
FORMATOPTION "INTERLACE=OFF"
END
QUERYMAP
COLOR 255 255 0
SIZE -1 -1
STATUS OFF
STYLE HILITE
END
WEB
IMAGEPATH "/"
IMAGEURL "/ms_tmp/"
METADATA
END
QUERYFORMAT text/html
END
LAYER
NAME 'bou2_4p'
TYPE POLYGON
EXTENT 49.189774-3.159989 173.282634 76.327090
DATA 'D:/project/test/bou2_4m/bou2_4p.shp'
METADATA
'wms_title' 'bou2_4p'
END
STATUS DEFAULT
TRANSPARENCY 20
PROJECTION
'proj=longlat'
'ellps=WGS84'
'datum=WGS84'
'no_defs'
END
CLASS
NAME 'bou2_4m'
STYLE
SYMBOL 0
SIZE 6
OUTLINECOLOR 255 130 120
COLOR 0 255 0
END
END
END
LAYER
NAME 'bou2_4l'
TYPE LINE
EXTENT 49.189774-3.159989 173.282634 76.327090
DATA 'D:/project/test/bou2_4m/bou2_4l.shp'
METADATA
'wms_title' 'bou2_4l'
END
STATUS DEFAULT
TRANSPARENCY 80
PROJECTION
'proj=longlat'
'ellps=WGS84'
'datum=WGS84'
'no_defs'
END
CLASS
NAME 'bou2_4l'
STYLE
SYMBOL 0
SIZE 36
OUTLINECOLOR 255 0 0
COLOR 0 0 250
END
END
END
END
.html为
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
OpenLayer : Map Controls
<br>
#wrapper<br>
{<br>
width: 1000px;<br>
}<br>
#location {<br>
float: right;<br>
}<br>
#scale {<br>
float: left;<br>
}<br>
html, body { width: 100%; height: 100%; margin: 0; padding: 0; }
var map = null;
var wms_url = "http://192.168.0.129/cgi-bin/mapserv.exe?MAP=D:/installed/ms4w/Apache/htdocs/test.map";
var wms_layer0 = "bou2_4p";
var wms_layer1 = "bou2_4l"
var wms_format = 'image/png';
function init()
{
//创建map对象,
map = new OpenLayers.Map("map");
var layer0 = new OpenLayers.Layer.WMS("layer0",
wms_url,
{
layers : wms_layer0,
format : wms_format,
singleTile: true,
Mode:'MAP'
},
{ isBaseLayer: true});
var layer1 = new OpenLayers.Layer.WMS("layer1",
wms_url,
{
layers : wms_layer1,
format : wms_format,
singleTile: true,
Mode:'MAP'
},
{ isBaseLayer: true});
// 添加图层
map.addLayers([layer0, layer1]);
map.numZoomLevels =13; //设置缩放级别
//OpenLayers中默认加载的控件有4个:Navigation、Zoom、Attribution、ArgParser,地图初始化完成后,移除Zoom控件
var zoomControl = map.getControlsByClass('OpenLayers.Control.Zoom')[0];
map.removeControl(zoomControl);
// 添加Layer Switcher控件 图层切换 右上
map.addControl( new OpenLayers.Control.LayerSwitcher());
// 添加Mouse Position控件 显示鼠标所在位置坐标 正下
map.addControl(new OpenLayers.Control.MousePosition({element: $('location')}));
// 添加Map Scale控件
map.addControl(new OpenLayers.Control.Scale($('scale')));
// 添加PanZoomB 缩放控件 左上
map.addControl(new OpenLayers.Control.PanZoomBar());
map.addControl(new OpenLayers.Control.Permalink());
//显示比例尺 左下
map.addControl(new OpenLayers.Control.ScaleLine());
//显示鹰眼 右下
map.addControl(new OpenLayers.Control.OverviewMap());
//显示经纬度
//map.addControl(new OpenLayers.Control.Graticule());
//添加绘制工具
//map.addControl(new OpenLayers.Control.EditingToolbar());
//添加导航控件
//map.addControl(new OpenLayers.Control.Navigation());
// 放大到全屏
map.zoomToMaxExtent();
}
不知道什么问题,请教?谢谢