OpenLayers 3 WMS 图层 - EPSG:2180 投影中错位的图块
OpenLayers 3 WMS Layer - Misplaced tiles in EPSG:2180 projection
我正在尝试使用 OpenLayers 3 显示波兰地图。我需要它在投影中 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>
知道问题出在哪里吗?
我添加了一个元素 - 它防止了轴问题。
params: {
'LAYERS': 'Raster',
'CRS': 'EPSG:2180',
'VERSION': '1.1.1'
}
我正在尝试使用 OpenLayers 3 显示波兰地图。我需要它在投影中 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>
知道问题出在哪里吗?
我添加了一个元素 - 它防止了轴问题。
params: {
'LAYERS': 'Raster',
'CRS': 'EPSG:2180',
'VERSION': '1.1.1'
}