如何匹配 Openlayers 源和图层?

How to match Openlayers source and layers?

Opanlayers 当前版本有 layersource 个对象来查看矢量或平铺图像。

图层类型:图像、平铺和矢量

源类型: ImageWMS、TileWMS、Geojson、OSM、光栅、矢量……

那么我如何决定哪个 source 与哪个 layer 一起工作?我在 openlayers documents 页面找不到。

接受的源类型显示在图层类型的文档中。它适用于 Image、Vector 和 VectorTile。 subclasses 在源类型的文档中列出时,通常使用它们代替基本 class。文档混淆地将基础 class Tile 显示为 Tile 层的源类型。其中的 Subclasses 包括不合适的 VectorTile,因为它仅由 VectorTile 层使用,而 Tile 层仅使用 TileImage 或(很少)TileDebug 或 UFTGrid 的子classes。 OSM 是 XYZ 的子class。 OpenLayers 5 中没有 GeoJSON 源类型,它只是 Vector 源使用的格式之一。

https://openlayers.org/en/latest/apidoc/module-ol_layer_Tile-TileLayer.html uses subclasses of https://openlayers.org/en/latest/apidoc/module-ol_source_TileImage-TileImage.html or https://openlayers.org/en/latest/apidoc/module-ol_source_TileDebug-TileDebug.html or https://openlayers.org/en/latest/apidoc/module-ol_source_UTFGrid-UTFGrid.html

https://openlayers.org/en/latest/apidoc/module-ol_layer_Image-ImageLayer.html 使用子classes https://openlayers.org/en/latest/apidoc/module-ol_source_Image-ImageSource.html

https://openlayers.org/en/latest/apidoc/module-ol_layer_Vector-VectorLayer.html uses https://openlayers.org/en/latest/apidoc/module-ol_source_Vector-VectorSource.html

https://openlayers.org/en/latest/apidoc/module-ol_layer_VectorTile-VectorTileLayer.html uses https://openlayers.org/en/latest/apidoc/module-ol_source_VectorTile-VectorTile.html