由于工作需要,本人开始用mapserver(WMS)+Openlayers不久
我自己在本机架设的WMS地图服务, 其中mapfile使用qgis生成的,然后手动进行了更改。
然后按照网上的资料,用了“http://127.0.0.1/cgi-bin/mapserv.exe?map=C:\ms4w\apps\test-mapserv\testmap.map&layers=cgd106p020”测试能够在浏览器生成地图,
接着用“http://127.0.0.1/cgi-bin/mapserv.exe?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities&map=C:\ms4w\apps\test-mapserv\testmap.map”测试能够在浏览器显示XML文件
但是我在用Openalyer些的网页测试我自己的WMS地图时始终不能显示,但是我用其他WMS比如“http://vmap0.tiles.osgeo.org/wms/vmap0”时却能显示地图。
我的mapfile:
******************************************************
MAP
NAME "test1"
SIZE 600 400
UNITS meters
EXTENT -188.106432 -115.500551 188.761248 204.573292
FONTSET 'C:\ms4w\apps\gmap\etc\fonts.txt'
SYMBOLSET 'C:\ms4w\apps\gmap\etc\symbols.txt'
PROJECTION
"init=epsg:4326"
END
IMAGECOLOR 255 255 255
IMAGEQUALITY 95
IMAGETYPE png
OUTPUTFORMAT
NAME png
DRIVER 'GD/PNG'
MIMETYPE 'image/png'
IMAGEMODE RGBA
EXTENSION 'png'
END
LEGEND
IMAGECOLOR 255 255 255
STATUS ON
KEYSIZE 18 12
LABEL
TYPE BITMAP
SIZE MEDIUM
COLOR 0 0 89
END
END
WEB
IMAGEPATH 'C:/ms4w/tmp/ms_tmp/'
IMAGEURL '/ms_tmp/'
METADATA
'wms_title' 'test1'
'wms_onlineresource' 'http://127.0.0.1/cgi-bin/mapserv.exe?map=C:\ms4w\apps\test-mapserv\testmap.map'
'wms_srs' 'EPSG:4326'
END
TEMPLATE 'index.html'
END
LAYER
NAME 'cgd106p020'
TYPE POLYGON
DUMP true
TEMPLATE fooOnlyForWMSGetFeatureInfo
EXTENT -179.133392 17.674692 179.788208 71.398048
DATA 'C:\ms4w\apps\test-mapserv\data\cgd106p020.shp'
METADATA
'wms_title' 'cgd106p020'
END
STATUS OFF
TRANSPARENCY 100
PROJECTION
"init=epsg:4326"
END
CLASS
NAME 'cgd106p020'
STYLE
WIDTH 0.91
OUTLINECOLOR 0 0 0
COLOR 122 140 101
END
END
END
END
********************************************
我的Openlayer页面
......
var map = new OpenLayers.Map('map', {controls: []});
var extent = new OpenLayers.Bounds(-179.133392, 17.674692, 179.788208, 71.398048);
var wms_baselayer = new OpenLayers.Layer.WMS('Base Layer', 'http://127.0.0.1/cgi-bin/mapserv.exe?map=C:\ms4w\apps\test-mapserv\testmap.map', {layers: 'cgd106p020'}, {isBaseLayer: true});
map.addLayer(wms_baselayer)
......
希望高手帮忙解答!!!!!!!!
------解决方案--------------------
我也碰到了同样的问题,怀疑是不是new OpenLayers.Layer.WMS(。。。)配置写的不对
------解决方案--------------------
帮顶啦
------解决方案--------------------
var wms_baselayer = new OpenLayers.Layer.WMS('Base Layer', 'http://127.0.0.1/cgi-bin/mapserv.exe?map=C:\ms4w\apps\test-mapserv\testmap.map', {layers: 'cgd106p020'}, {isBaseLayer: true});
改为:
var wms_baselayer = new OpenLayers.Layer.WMS(“Base Layer”, "http://127.0.0.1/cgi-bin/mapserv.exe?" , {layers: 'cgd106p020',map:'C:\ms4w\apps\test-mapserv\testmap.map',IMAGETYPE:'PNG'}, {isBaseLayer: true});
我的这样就可以了
------解决方案--------------------
请问楼哥,wms服务怎么搭建的,最近小弟正好用着。
------解决方案--------------------