Openlayers3とgeoserver/geowebcacheをバックエンドとして使用して小さなWebマップを作成しています。Openlayers3:バックグラウンドとしてGeoserver/Geowebcacheを使用してpixelratio = 3のタイルグリッドが正しくありません
私の目標は、pixelratio = 1、pixelratio = 2、pixelratio = 3のブラウザ/ディスプレイをサポートすることです。
そのために、タイルサイズ256x256,512x512、および768x768のジオサーババックエンド3グリッドセットで定義しました。 私は仮定する:
- pixelratio = 1タイルとgridsetが256×256
- pixelratio = 2タイルとgridset = 3 512×512
- pixelratioタイルとgridsetは768x768
ここで、私のコードはpixelratio = 1とpixelratio = 2だけで動作しています。 しかしpixelratio = 3 geowebcache場合はエラーを返します。
geowebcache-cache-result:MISS
geowebcache-miss-reason:request does not align to grid(s) 'grid_512' 'grid_768' 'grid_256'
pixelratio = 3 OpenLayersを、このようなURLを生成した場合:
http://localhost:8082/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=false&layers=mfn_mwb17%3Amfn_mwb17_0_basemap&TILED=true&WIDTH=768&HEIGHT=768&SRS=EPSG%3A32632&STYLES=&FORMAT_OPTIONS=dpi%3A270&BBOX=536964.8438079988%2C5280880.182948656%2C537609.9638079988%2C5281525.3029486565
Openalayersは270に768x768とDPIにタイルのサイズを変更しますが、明らかにしませんグリッドを正しく計算します。
Geoserverのデモマップ(Openlayers2に基づく)は、3つのグリッドセットすべてで動作します。
私はgeoserver 2.10とgoogle chromeを使用しています。 これまでのコードです。解決策と境界は、バックエンドの3つのグリッドセットすべてで同じです。すべてのヘルプは高く評価されています
<html>
<head>
<title>WMS Tiles</title>
<link rel="stylesheet" href="https://openlayers.org/en/v3.19.1/css/ol.css" type="text/css">
<!-- The line below is only needed for old environments like Internet Explorer and Android 4.x -->
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script>
<script src="https://openlayers.org/en/v3.19.1/build/ol.js"></script>
</head>
<body>
<div id="map" class="map"></div>
<script>
console.log("DOMContentLoaded");
try {
var config = {
"bounds": {
"left": 536319.7238079988,
"bottom": 5278944.822948656,
"right": 540150.3790103362,
"top": 5282223.663765706
}
};
var bounds = [config.bounds.left, config.bounds.bottom, config.bounds.right, config.bounds.top];
var resolutions = [2.5199999999999996,
1.2599999999999998,
0.6299999999999999,
0.31499999999999995,
0.15749999999999997,
0.07874999999999999,
0.03937499999999999
];
var projection = new ol.proj.Projection({
code: 'EPSG:32632'
});
var params = {
'VERSION': '1.1.1',
'layers': "mfn_mwb17:mfn_mwb17_0_basemap",
'TILED': true,
'TRANSPARENT': false
};
var tileGrid = new ol.tilegrid.TileGrid({
extent: bounds,
resolutions: resolutions,
origin: [config.bounds.left, config.bounds.bottom],
tileSize: [256, 256]
});
var view = new ol.View({
zoom: 0,
center: ol.extent.getCenter(bounds),
projection: projection,
resolutions: resolutions
});
var map = new ol.Map({
controls: ol.control.defaults(
{
rotate: false,
attributionOptions: {
collapsible: false
}
}
),
view: view,
layers: [
new ol.layer.Tile({
source: new ol.source.TileWMS({
url: "http://localhost:8082/wms",
params: params,
tileGrid: tileGrid,
serverType: 'geoserver'
}),
projection: projection,
extend: bounds
})
],
target: 'map'
});
console.log("no error");
} catch (error) {
console.log("error");
console.log(error);
}
</script>
</body>
</html>
ありがとうございます! 'tilePixelRatio:tilePixelRatio'がトリックをしました。しかし、今はTMSプロトコルを使って同じことをテストしています。私はここで新しい質問をしました:http://stackoverflow.com/questions/41056640/geowebcache-openlayers3-with-xyz-source-error-by-zooming-the-map。多分あなたは一見を与えることができます。 –