我正在使用OL3和mapserver ......我遇到的问题是MapServer似乎运行正常, 我有一个.map文件,对于像这样的“州”说...
MAP
IMAGETYPE PNG24
CONFIG "PROJ_LIB" "C:/Program Files/MapServer/projlib/"
EXTENT -180 -90 180 90
SIZE 256 256
FONTSET "E:/RCIS/Web/MapServerDlls/content/fontset.txt"
IMAGECOLOR 255 255 255
TRANSPARENT ON
PROJECTION
AUTO
END
LAYER
GROUP "Base"
NAME "States"
TYPE POLYGON
STATUS ON
LABELCACHE ON
PROCESSING 'LABEL_NO_CLIP=1'
CONNECTIONTYPE PLUGIN
PLUGIN "msplugin_mssql2008.dll"
CONNECTION "server=stbisqlr3.dvcorp.rcis.com,5208;uid=Mapping01D;pwd=9GreenSnap#4D;Initial Catalog=NATIONALDB;Integrated Security=False"
DATA "shape(geography),ST_NAME_MC from NATIONALDB.sde.STATES USING INDEX STATES_SIDX USING UNIQUE STATES_ID USING SRID=4269"
LABELITEM "ST_NAME_MC"
CLASS
STYLE
OUTLINECOLOR 000 153 000
WIDTH 3
END
LABEL
COLOR 000 153 000
TYPE TRUETYPE
FONT Arial
SIZE 12
ANTIALIAS FALSE
POSITION AUTO
PARTIALS FALSE
MINDISTANCE 2000
MINSCALEDENOM 20.00
END
END
PROJECTION
AUTO
END
END
END
我在OL3中构建我的地图......
control.map = new ol.Map({
target: 'map',
renderer: 'canvas',
layers: [],
view: new ol.View({
projection: 'EPSG:4326',
center: [0, 0],
zoom: 12
})
});
创建一个矢量图层,用于确定范围,创建视图,并显示矢量对象......哪个有效!!
vectorObjs.promise.then(function () {
//Create empty extent
var extent = ol.extent.createEmpty();
//Loop through vector layers to add them to map and determine extent
var totalExtent = ol.extent;
angular.forEach(webMapValues.vectorFieldLayer, function (Field, key) {
control.map.addLayer(Field);
extent = Field.getSource().getExtent();
totalExtent = ol.extent.extend(extent, totalExtent);
})
control.map.getView().fit(totalExtent, control.map.getSize());
var view = new ol.View({
center: control.map.getView().getCenter(),
zoom: 8,
minZoom: 1,
maxZoom: 19
});
control.map.view = view;
然后我尝试将状态图层添加到地图中,一切看起来都在工作,但我看不到任何状态图块?
var States = new ol.layer.Tile({
name: 'States',
extent: totalExtent,
source: new ol.source.TileWMS({
url: 'http://dvfmweb2:80/mapserver/mapserv.exe?map=E:/RCIS/Web/Mapfiles/MappingBase.map&',
params: { 'LAYERS': 'States', 'BBOX': totalExtent, 'TILED': true }
})
});
control.map.addLayer(States);
当我执行通话时,我会在Chrome开发工具中看到几个指示状态图块的订单项,即
当我用瓷砖取回瓷砖时,这是完整的信息。 1.请求网址:
的http:// 服务器名 /mapserver/mapserv.exe?地图= E:/RCIS/Web/Mapfiles/MappingStates.map&&安培; SERVICE = WMS&安培; VERSION = 1.3.0&安培; REQUEST =的GetMap&安培; FORMAT =图像%2Fpng&安培; TRANSPARENT =真安培; LAYERS =美国&安培; BBOX = 47.318115234375%2C -109.423828125%2C47.3291015625%2C-109.412841796875&安培;瓷砖=真安培; WIDTH = 256&安培; HEIGHT = 256&安培; CRS = EPSG%3A4326&安培;花柱
请求方法: GET
状态代码: 200 OK
其他信息!!!
当我粘贴其中一个链接获得“200 Ok”返回码时,我可以看到一个错误,上面写着......
<ServiceException code="InvalidSRS">
msWMSLoadGetMapParams(): WMS server error. Invalid CRS given : CRS must be valid for all requested layers.
</ServiceException>
但是我只看到白色?
非常感谢任何帮助,我一直在敲打太长时间!
-Bob
答案 0 :(得分:0)
事实证明,地图文件未正确构建是一个问题。 以上是一个有效的地图文件,但要求必须更改...下面是一个有效的地图文件。这可以用作系统的模板...请注意您需要填写的地图文件中的所有“您的......”位置。
MAP
IMAGETYPE PNG24
CONFIG "PROJ_LIB" "E:/your/path/to/projlib"
SIZE 256 256
FONTSET "E:/your/path/to/fontset.txt"
IMAGECOLOR 255 255 255
TRANSPARENT ON
PROJECTION
"init=epsg:4326"
END
WEB
METADATA
"wms_title" "states"
"wms_enable_request" "*"
END
END
LAYER
NAME "States"
TYPE POLYGON
STATUS ON
LABELCACHE ON
PROCESSING 'LABEL_NO_CLIP=1'
CONNECTIONTYPE PLUGIN
PLUGIN "msplugin_mssql2008.dll"
CONNECTION "server=YourServername.com,YourPort;uid=YouruserID;pwd=YourDBPassword;Initial Catalog=YourDatabaseName;Integrated Security=False"
DATA "shape(geography),YourStateColumnName from YourDatabaseName.STATES USING INDEX YourTableIndex USING UNIQUE YourStateIDColumn USING SRID=4269"
LABELITEM "YourStateNameColumn"
PROCESSING "CLOSE_CONNECTION=DEFER"
CLASS
STYLE
OUTLINECOLOR 000 153 000
WIDTH 3
END
LABEL
COLOR 000 153 000
TYPE TRUETYPE
FONT Arial
SIZE 12
ANTIALIAS FALSE
POSITION AUTO
PARTIALS FALSE
END
END
PROJECTION
"init=epsg:4326"
END
END
END
然后保存为States.map并从WMS指向它
答案 1 :(得分:0)
您只能请求服务/图层支持列出的CRS。因此您遇到了错误,因为您的图层未将EPSG:4326
列为支持。
要列出支持多个CRS,您需要将METADATA部分添加到表示支持CRS的图层(或服务或两者)中,如:
METADATA
"WMS_SRS" "CRS:84 EPSG:3857 EPSG:4269 EPSG:4326"
END