I'm using GeoServer 2.10.1 and its built-in GeoWebCache and am trying to use a cached background layer in a custom gridset with a local epsg to work in a simple Ol3 app:
proj4.defs("EPSG:3010","+proj=tmerc +lat_0=0 +lon_0=16.5 +k=1 +x_0=150000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +axis=neu +no_defs");
var projection = new ol.proj.Projection({
code: 'EPSG:3010',
extent: [-2138120,3880750,2396422,8973750] //Matches GWC gridset
});
var wmsSource = new ol.source.TileWMS({
url: 'http.../geoserver/wms',
projection: 'EPSG:3010',
params: {'LAYERS': 'basemap', 'tiled': true, 'version':'1.1.1'}
});
var wmsLayer = new ol.layer.Tile({
source: wmsSource
});
var view = new ol.View({
resolutions: [4200,1399.9999999999998,560,140,55.9999999999999,27.99999999999996..], //Matching GWC gridset
center: [151423.169, 6908747.899],
extent: [-2138120,3880750,2396422,8973750],
zoom: 1,
projection: projection
});
var map = new ol.Map({
layers: [wmsLayer],
target: 'map',
view: view
});
This produces a map with a fuzzy, "zoomed out" look at every zoom level (but the tiles returned actually look good and view.getResolution
reports the correct resolution). GWC says "does not align to gridset" for every getMap.
If I let OL calculate the zoom levels the base map looks fine.
If I use
url: 'http...geoserver/gwc/service/wms'
instead I get http 400 bad request
on the getMap
requests.
The base layer is used as a background map in an ol2 app defined in the same way, i.e extent and a series of resolutions, and it works well.
What is required in OL3 to make use of a cached background layer?
ol.layer.Tile
if you want to get the tiles out of the GeoWebCache --> openlayers.org/en/latest/apidoc/ol.layer.Tile.html. And you also need to create a cached layer within geoserver