Reputation: 41
Im using openlayers 4.6.5 and I try to catch the error like
function onLoadDie(evt){
console.log("this tile does not load :", evt);
}
var source_xyz = new ol.source.XYZ({
url: f_url,
minZoom: 15,
});
source_xyz.addEventListener('tileloaderror', onLoadDie);
The 404 still propagates to the console. Here is the console output plus the response from Geoserver that produces the 404. I tried to fix Geoserver layer with no luck either.
Failed to load resource: the server responded with a status of 404 (Not Found) Coverage [minx,miny,maxx,maxy] is [71508, 85624, 71511, 85627, 17], index [x,y,z] is [71512, 85626, 17]
Upvotes: 1
Views: 2552
Reputation: 41
By manually adding the extent property to your ol.layer.tile layer upon creation in openlayers 3.x 4.x The extent property will NOT try to load tiles outside of this extent and therefor suppress a 400 or 404 repsonse from Geoserver. My data is in this case in EPSG:3857 and therefor so is my extent. Extent is defined as [minx, miny, maxx, maxy]
var tmp_lyr = new ol.layer.Tile({
source: source_xyz,
extent: [1826159,6142088, 1826967, 6142874],
visible: is_visible,
name: name,
floor_num: floor,
type: 'floor',
zIndex: zIndex,
crossOrigin: "anonymous"
});
Upvotes: 2