Openlayers 3 如何在Openlayer 3 WMS(mapserver)中修改CRS?

Openlayers 3 如何在Openlayer 3 WMS(mapserver)中修改CRS?,openlayers-3,mapserver,Openlayers 3,Mapserver,我使用Openlayer3通过MapServer WMS添加光栅层。 加载页面时,WMS URL中的CRS值更改为3857 工作映射服务器URL :\mapserver\ImplementImage.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&LAYERS=Gujarat&STYLES=&CRS=EPSG:32643&BBOX=361600.5189140513524040154.8014285564366487.01241288962409041.

我使用Openlayer3通过MapServer WMS添加光栅层。 加载页面时,WMS URL中的CRS值更改为3857

工作映射服务器URL

:\mapserver\ImplementImage.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&LAYERS=Gujarat&STYLES=&CRS=EPSG:32643&BBOX=361600.5189140513524040154.8014285564366487.01241288962409041.294927395&WIDTH=800&HEIGHT=500&FORMAT=image/png

openlayer正在请求下面的URL

解码为

:\mapserver\ImplementImage.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image/png&TRANSPARENT=true&LAYERS=Gujarat&CRS=EPSG:3857&BBOX=360378.89553934172402933.1780538466367708.63578759952410262.918302105&WIDTH=1&HEIGHT=1&STYLES=

下面是Openlayer代码

var layers = [
            new ol.layer.Image({
                extent: [361600.51891405135,2404154.8014285564,366487.01241288986,2409041.294927395],
                source: new ol.source.ImageWMS({
                    url: encodeURI('http://localhost/cgi-bin/mapserv.exe?map=D:\\mapserver\\actualimage.map'),
                    params: {
                        'LAYERS': 'Gujarat',
                        'CRS': 'EPSG:32643',
                        'BBOX': '361600.51891405135,2404154.8014285564,366487.01241288986,2409041.294927395',
                        'WIDTH': '800',
                        'HEIGHT': '500',
                        'FORMAT': 'image/png'
                    },
                    serverType: 'mapserver',
                    projection: ol.proj.get('EPSG:32643'),
                })
            })
        ];
        var map = new ol.Map({
            layers: layers,
            target: 'map',
            view: new ol.View({
                center: [361600.51891405135, 2404154.8014285564],
                zoom: 1
            })
        });

除非您已将
'EPSG:32643'
注册为投影(例如,通过使用和配置proj4js),
ol.proj.get('EPSG:32643')
将返回
null
。如果投影已正确注册,OpenLayers会将WMS层光栅重新投影到视图投影(
'EPSG:3857'
),您可能需要,也可能不需要


要不进行光栅重投影,请在ol.source.ImageWMS
ol.View
上配置投影:“EPSG:32643”。还请注意,在这种情况下,视图中心的坐标必须在“EPSG:32643”中。

除非您已将“EPSG:32643”注册为投影(例如通过使用和配置proj4js),
ol.proj.get('EPSG:32643')
将返回
null
。如果投影已正确注册,OpenLayers会将WMS层光栅重新投影到视图投影(
'EPSG:3857'
),您可能需要,也可能不需要

要不进行光栅重投影,请在
ol.source.ImageWMS
ol.View
上配置投影:“EPSG:32643”。还要注意,在这种情况下,视图的
中心
的坐标需要在`'EPSG:32643'