2015-07-22 53 views
1

我試圖用OpenLayers 3顯示波蘭地圖。我需要它在投影EPSG:2180。除非我切換投影,否則不要緊。OpenLayers 3 WMS圖層 - 錯位的EPSG貼圖:2180投影

這工作得很好:

<!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

我必須添加一個元素 - 它防止軸問題。

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

嘗試這樣的:jsfiddle.net/b2L6qppd/2/

相關問題