模块:ol/source/VectorTile

ol/source/VectorTile


VectorTile

类型定义

Options{Object}

属性:
Name Type 描述
attributions AttributionLike | undefined

归属。

attributionsCollapsible boolean
(defaults to true)

署名是可折叠的。

cacheSize number | undefined

初始瓦片缓存大小将自动增长,以至少容纳视口中瓦片数量的两倍。

extent Extent | undefined

范围.

format FeatureFormat<FeatureType> | undefined

瓦片要素格式。默认使用且必需。

overlaps boolean
(defaults to true)

该数据源可能包含重叠的几何体。将其设置为false例如,对于包含代表行政边界的多边形或 TopoJSON 格式的数据源,渲染器可以优化填充和描边操作。

projection ProjectionLike
(defaults to 'EPSG:3857')

瓦片源的投影。

state State | undefined

源状态。

tileClass Class<VectorTile> | undefined

用于实例化图块的类。默认为VectorTile.

maxZoom number
(defaults to 22)

可选的最大缩放级别。若不使用,tileGrid已提供。

minZoom number | undefined

可选的最小缩放级别。如果不使用。tileGrid已提供。

tileSize number | Size
(defaults to 512)

可选瓦片尺寸。条件成立时未使用。tileGrid已提供。

maxResolution number | undefined

零级可选瓦片网格分辨率。如果不使用tileGrid已提供。

tileGrid TileGrid | undefined

瓦片 网格.

tileLoadFunction LoadFunction | undefined

用于根据给定URL加载瓦片的可选函数。对于pbf瓦片,其形式可能如下:

function(tile, url) {
  tile.setLoader(function(extent, resolution, projection) {
    fetch(url).then(function(response) {
      response.arrayBuffer().then(function(data) {
        const format = tile.getFormat() // ol/format/MVT configured as source format
        const features = format.readFeatures(data, {
          extent: extent,
          featureProjection: projection
        });
        tile.setFeatures(features);
      });
    });
  });
}

如果您不需要范围、分辨率和投影来获取图块的要素(例如 GeoJSON 图块),您的tileLoadFunction无需setLoader()调用。只需确保调用setFeatures()在瓦片上:

const format = new GeoJSON({featureProjection: map.getView().getProjection()});
async function tileLoadFunction(tile, url) {
  const response = await fetch(url);
  const data = await response.json();
  tile.setFeatures(format.readFeatures(data));
}
tileUrlFunction UrlFunction | undefined

可选函数,用于根据瓦片坐标和投影获取瓦片URL。

url string | undefined

URL模板。必须包含{x}, {y}{-y}{z}占位符。A{?-?}例如模板模式subdomain{a-f}.domain.com,可用于代替在...中分别定义每个urls选项。

transition number | undefined

瓦片不透明度过渡的持续时间(毫秒)。持续时间为 0 时禁用不透明度过渡。

urls Array.<string> | undefined

URL模板数组

wrapX boolean
(defaults to true)

是否水平环绕世界。当设置为false,只会渲染一个世界。当设置为true,瓦片将水平包裹以渲染多个世界。

zDirection number | NearestDirectionFunction
(defaults to 1)

选择在整数缩放级别之间是否使用更高或更低缩放级别的瓦片。参见getZForResolution.