我在EPSG中有一个GeoServer 2.5实例托管层服务:4326并且被OpenLayers 3地图使用,默认EPSG:3857投影。一切都可以使用基本的wms图层,但是气泡和标签的碎片要求我使用单个Tile或Meta-Tiled WMS请求。
我正在构建具有geoserver必需属性的图层对象,但OpenLayers会覆盖其中许多我认为阻止Meta-Tiling实际工作的图层对象。
这在Leaflet中非常有用,所以我知道GeoServer上没有问题所以我必须要找到一些我不知道的东西。非常感谢任何帮助。
var mapBounds = this.getCurrentBounds('EPSG:4326');
var mapSWOrigin = [mapBounds._southWest.lng, mapBounds._southWest.lat].toString();
var wmsLayer = new ol.layer.Tile({
extent: [-20026376.39, -20048966.10, 20026376.39, 20048966.10], //epsg:3857 extent
preload: true,
source: new ol.source.TileWMS({
url: window.location.origin+"/geoserver/wms/",
params: {
'LAYERS': geoserverName,
'VERSION': '1.3',
'SRS': 'EPSG:4326', // THIS GETS OVERWRITTEN. also tried EPSG:3857
'BBOX': extent, //THIS GETS OVERWRITTEN. Tried extent of the current state of the map and the extent of the projection (ex: [21.99937, -18.07947, 33.7057, -8.22436])
'TILED': true,
'STYLES': layer.getSldName() || "",
'TILESIZE': 256,
'FORMAT': 'image/png',
'TILESORIGIN': mapSWOrigin
},
serverType: 'geoserver'
}),
visible: true
});
从浏览器控制台捕获的结果请求:
https://localhost:8443/geoserver/wms/?SERVICE=WMS
&VERSION=1.3.0
&REQUEST=GetMap
&FORMAT=image%2Fpng
&TRANSPARENT=true
&LAYERS=geodashboard%3Alv_sjym3xbpypz4un9nm3xnvy6873p1k1nn_1psl34vde5
&BBOX=3757032.814272985%2C-1252344.271424327%2C5009377.085697313%2C6.984919309616089e-10 // NOTICE THIS IS NOT EPSG:4326 UNITS
&TILED=true
&STYLES=lv_sjym3xbpypz4un9nm3xnvy6873p1k1nn_1psl34vde5
&TILESIZE=256
&TILESORIGIN=9.428462734375003%2C-18.869002237258456
&WIDTH=282
&HEIGHT=282
&CRS=EPSG%3A3857 // NOTICE THIS IS NOT EPSG:4326
&FORMAT_OPTIONS=dpi%3A99
答案 0 :(得分:0)
您正在使用SRS而不是WMS 1.3所需的CRS。
最诚挚的问候, 格哈德
答案 1 :(得分:0)
试用示例代码
var z = tileCoord[0];
var x = tileCoord[1];
var y = tileCoord[2];
var tileGrid = source.getTileGrid();
var tileGridOrigin = tileGrid.getOrigin();
var tileSizeAtResolution = tileGrid.getTileSize(z) * tileGrid.getResolution(z);
return [
tileGridOrigin[0] + tileSizeAtResolution * x,
tileGridOrigin[1] + tileSizeAtResolution * y,
tileGridOrigin[0] + tileSizeAtResolution * (x + 1),
tileGridOrigin[1] + tileSizeAtResolution * (y + 1)
];