Module: ol/source/VectorTile

ol/source/VectorTile


Classes

VectorTile

Type Definitions

Options{Object}

Properties:
Name Type Description
attributions AttributionLike | undefined

归属信息。

attributionsCollapsible boolean
(defaults to true)

归属信息是否可折叠。

cacheSize number | undefined

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

extent Extent | undefined

范围。

format 要素Format<要素Type> | 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

瓦片网格。

tileLoad函数 Load函数 | 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.read要素s(data, {
          extent: extent,
          featureProjection: projection
        });
        tile.set要素s(features);
      });
    });
  });
}

如果您不需要范围、分辨率和投影来获取瓦片的要素(例如 GeoJSON 瓦片),您的 tileLoad函数 不需要调用 setLoader()。只需确保在瓦片上调用 set要素s()

const format = new GeoJSON({featureProjection: map.getView().getProjection()});
async function tileLoad函数(tile, url) {
  const response = await fetch(url);
  const data = await response.json();
  tile.set要素s(format.read要素s(data));
}
tileUrl函数 Url函数 | undefined

给定瓦片坐标和投影获取瓦片 URL 的可选函数。

url string | undefined

URL 模板。必须包含 {x}{y}{-y},以及 {z} 占位符。可以使用 {?-?} 模板模式(例如 subdomain{a-f}.domain.com)来代替在 urls 选项中逐个定义。

transition number | undefined

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

urls Array.<string> | undefined

URL 模板数组。

wrapX boolean
(defaults to true)

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

zDirection number | NearestDirection函数
(defaults to 1)

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