GeoTIFF 带概览
GeoTIFF 带概览示例。 COG 鹰眼
在某些情况下,GeoTIFF 可能带有外部概览文件。本示例使用 overviews 属性提供包含外部概览的文件的 URL。
main.js
js
import Map from 'ol/Map.js';
import TileLayer from 'ol/layer/WebGLTile.js';
import GeoTIFF from 'ol/source/GeoTIFF.js';
const source = new GeoTIFF({
sources: [
{
url: 'https://openlayers.org/data/raster/no-overviews.tif',
overviews: ['https://openlayers.org/data/raster/no-overviews.ovr.tif'],
},
],
});
const map = new Map({
target: 'map',
layers: [
new TileLayer({
source: source,
}),
],
view: source.getView(),
});index.html
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>带概览的 GeoTIFF</title>
<link rel="stylesheet" href="node_modules/ol/ol.css">
<style>
.map {
width: 100%;
height: 400px;
}
</style>
</head>
<body>
<div id="map" class="map"></div>
<script type="module" src="main.js"></script>
</body>
</html>package.json
json
{
"name": "cog-overviews",
"dependencies": {
"ol": "10.11.0"
},
"devDependencies": {
"vite": "^8.1.5"
},
"scripts": {
"start": "vite",
"build": "vite build"
}
}