首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Openlayer 3 WMS (mapserver)中修改CRS?

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

Stack Overflow用户
提问于 2017-05-01 18:29:09
回答 1查看 626关注 0票数 0

我正在使用Openlayer3通过MapServer WMS添加一个栅格层。加载页面时,WMS URL中的CRS值将更改为3857。

工作地图服务器URL

http://localhost/cgi-bin/mapserv.exe?map=D:\mapserver\actualimage.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&LAYERS=Gujarat&STYLES=&CRS=EPSG:32643&BBOX=361600.51891405135,2404154.8014285564,366487.01241288986,2409041.294927395&WIDTH=800&HEIGHT=500&FORMAT=image/png

openlayer正在请求下面的URL

http://localhost/cgi-bin/mapserv.exe?map=D:%5Cmapserver%5Cactualimage.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=Gujarat&CRS=EPSG%3A3857&BBOX=360378.8955393417%2C2402933.1780538466%2C367708.6357875995%2C2410262.918302105&WIDTH=1&HEIGHT=1&STYLES=

解码为

http://localhost/cgi-bin/mapserv.exe?map=D:\mapserver\actualimage.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image/png&TRANSPARENT=true&LAYERS=Gujarat&CRS=EPSG:3857&BBOX=360378.8955393417,2402933.1780538466,367708.6357875995,2410262.918302105&WIDTH=1&HEIGHT=1&STYLES=

下面是Openlayer代码

代码语言:javascript
复制
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
            })
        });
EN

回答 1

Stack Overflow用户

发布于 2017-05-01 22:04:43

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

要不进行光栅重投影,请在这种情况下配置projection: 'EPSG:32643' on both yourol.source.ImageWMSand yourol.View. Also note that the coordinates of the view'scenterneed to be in ``'EPSG:32643'

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43717661

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档