英文:
Is there an implementation of GeoTIFF in OpenLayer 3?
问题
我需要在网站上使用OpenLayers 3添加一些(COG) GeoTIFF图层。由于我们还没有准备好升级到OpenLayers的当前版本,我一直在想是否有办法在OpenLayers 3中实现这个目标。
英文:
As the title says, I need to add some (COG) GeoTIFF layer to a website using openlayers 3.
Since we're not ready to upgrade to a current version of openlayers, I've been wondering whether there was a way to do so with openlayers 3.
答案1
得分: 1
GeoTIFF支持已在版本6.7.0中添加。 如果您保留Openlayers 3的原因是语法,您也可以使用OpenLayers 6和7作为完整构建,如下所示:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Cloud Optimized GeoTIFF (COG)</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/ol@v7.3.0/ol.css">
<style>
html, body, .map {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<div id="map" class="map"></div>
<script src="https://cdn.jsdelivr.net/npm/elm-pep@1.0.6/dist/elm-pep.js"></script>
<script src="https://cdn.jsdelivr.net/npm/geotiff"></script>
<script src="https://cdn.jsdelivr.net/npm/ol@v7.3.0/dist/ol.js"></script>
<script>
const source = new ol.source.GeoTIFF({
sources: [
{
url: 'https://sentinel-cogs.s3.us-west-2.amazonaws.com/sentinel-s2-l2a-cogs/36/Q/WD/2020/7/S2A_36QWD_20200701_0_L2A/TCI.tif',
},
],
});
const map = new ol.Map({
target: 'map',
layers: [
new ol.layer.WebGLTile({
source: source,
}),
],
view: source.getView(),
});
</script>
</body>
</html>
Please note that this is the translated code you provided.
英文:
GeoTIFF support was added in version 6.7.0. If your reason for keeping Openlayers 3 is the syntax you can also use OpenLayers 6 and 7 as a full build as below
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Cloud Optimized GeoTIFF (COG)</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/ol@v7.3.0/ol.css">
<style>
html, body, .map {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<div id="map" class="map"></div>
<script src="https://cdn.jsdelivr.net/npm/elm-pep@1.0.6/dist/elm-pep.js"></script>
<script src="https://cdn.jsdelivr.net/npm/geotiff"></script>
<script src="https://cdn.jsdelivr.net/npm/ol@v7.3.0/dist/ol.js"></script>
<script>
const source = new ol.source.GeoTIFF({
sources: [
{
url: 'https://sentinel-cogs.s3.us-west-2.amazonaws.com/sentinel-s2-l2a-cogs/36/Q/WD/2020/7/S2A_36QWD_20200701_0_L2A/TCI.tif',
},
],
});
const map = new ol.Map({
target: 'map',
layers: [
new ol.layer.WebGLTile({
source: source,
}),
],
view: source.getView(),
});
</script>
</body>
</html>
<!-- end snippet -->
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论