OpenLayers 3 WMS图层 - EPSG中错位的图块:2180投影

时间:2015-07-22 07:33:40

标签: openlayers-3 wms

我试图使用OpenLayers 3显示波兰地图。我需要它在投影EPSG:2180。在切换投影之前,Ewerything是可以的。

这很好用:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://openlayers.org/en/v3.7.0/build/ol.js" type="text/javascript"></script>
<script src="proj4js/proj4-src.js" type="text/javascript"></script>
<script>

proj4.defs('EPSG:2180', "+proj=tmerc +lat_0=0 +lon_0=19 +k=0.9993 +x_0=500000 +y_0=-5300000 +ellps=GRS80 +units=m +no_defs");

function init()
{
    var p = ol.proj.get('EPSG:3857');

    var mapTiles = new ol.Map({
        target: 'map',
        renderer: 'canvas',
        layers: [
            new ol.layer.Tile({
                source: new ol.source.TileWMS({
                    url: 'http://mapy.geoportal.gov.pl/wss/service/img/guest/ORTO/MapServer/WMSServer',
                    params: {
                        'LAYERS': 'Raster'
                    }
                }),
                isBaseLayer: true,
                projection: p
            })
        ],

        view: new ol.View({
            center: ol.proj.transform([19, 52], 'EPSG:4326', 'EPSG:3857'),
            zoom: 6,
            projection: p
        })
    });
}

</script>
</head>
<body onload="init()">
    <div id="map"></div>
</body>
</html>

当我将投影切换到EPSG时:2180个图块放错位置。

代码与EPSG:2180

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>test</title>
<script src="http://openlayers.org/en/v3.7.0/build/ol.js" type="text/javascript"></script>
<script src="proj4js/proj4-src.js" type="text/javascript"></script>
<script>

proj4.defs('EPSG:2180', "+proj=tmerc +lat_0=0 +lon_0=19 +k=0.9993 +x_0=500000 +y_0=-5300000 +ellps=GRS80 +units=m +no_defs");

function init()
{
    var p = ol.proj.get('EPSG:2180');

    var mapTiles = new ol.Map({
        target: 'map',
        renderer: 'canvas',
        layers: [
            new ol.layer.Tile({
                source: new ol.source.TileWMS({
                    url: 'http://mapy.geoportal.gov.pl/wss/service/img/guest/ORTO/MapServer/WMSServer',
                    params: {
                        'LAYERS': 'Raster',
                        'CRS': 'EPSG:2180'
                    }
                }),
                isBaseLayer: true,
                projection: p
            })
        ],

        view: new ol.View({
            center: ol.proj.transform([19, 52], 'EPSG:4326', 'EPSG:2180'),
            zoom: 6,
            projection: p
        })
    });
}

</script>
</head>
<body onload="init()">
    <div id="map"></div>
</body>
</html>

知道这是什么问题吗?

https://jsfiddle.net/b2L6qppd/

1 个答案:

答案 0 :(得分:1)

我添加了一个元素 - 它可以防止轴问题。

            params: {
                'LAYERS': 'Raster',
                'CRS': 'EPSG:2180',
                'VERSION': '1.1.1'
            }

试试这个:jsfiddle.net/b2L6qppd/2/