Classes
Type Definitions
-
接受
Tile(瓦片)和{string}(URL)作为参数的函数。默认为source.setTileLoad函数(function(tile, src) { tile.getImage().src = src; });要获得更细粒度的控制,加载函数可以使用 fetch 或 XMLHttpRequest,并涉及错误处理:
import TileState from 'ol/TileState.js'; source.setTileLoad函数(function(tile, src) { const xhr = new XMLHttpRequest(); xhr.responseType = 'blob'; xhr.addEventListener('loadend', function (evt) { const data = this.response; if (data !== undefined) { tile.getImage().src = URL.createObjectURL(data); } else { tile.setState(Tile状态。ERROR); } }); xhr.addEventListener('error', function () { tile.setState(Tile状态。ERROR); }); xhr.open('GET', src); xhr.send(); }); -
Options{Object}
-
Properties:
Name Type Description transitionnumber
(defaults to 250)瓦片不透明度过渡的持续时间(毫秒)。持续时间为 0 将禁用不透明度过渡。
interpolateboolean
(defaults to false)重采样时使用插值。 默认情况下, 重采样时使用最近邻。
-
TileSource数据源使用此类型的函数来获取给定瓦片坐标的瓦片 URL。此函数接受
TileCoord(瓦片坐标)、表示像素比的{number}和表示投影的Projection作为参数,返回表示瓦片 URL 的{string},如果不应为传入的瓦片坐标请求瓦片,则返回 undefined。