【问题标题】:How to modify CRS in Openlayer 3 WMS (mapserver)?如何在 Openlayer 3 WMS(地图服务器)中修改 CRS?
【发布时间】:2017-05-01 10:29:09
【问题描述】:

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

工作地图服务器网址

http://localhost/cgi-bin/mapserv.exe?map=D:\ mapserver \ amamicimage.map&service = wms&serview = 1.3.0&request = getmap&layers = gujarat&layers = gujarat&styles =&crs = epsg:32643和bbox = 361600.51891405135,240436487.012413664927395和宽度= 800&Height = 500&Format = 500&Format = Image / PNG P>

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:\地图服务器\ actualimage.map&SERVICE = WMS&VERSION = 1.3.0&REQUEST =的GetMap&FORMAT =图像/ PNG&TRANSPARENT =真LAYERS =古吉拉特&CRS = EPSG:3857&BBOX = 360378.8955393417,2402933.1780538466,367708.6357875995,2410262.918302105&WIDTH = 1&HEIGHT = 1&STYLES = P >

下面是 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
            })
        });

【问题讨论】:

    标签: openlayers-3 mapserver


    【解决方案1】:

    除非您已将'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'

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-15
      • 1970-01-01
      相关资源
      最近更新 更多