首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >开放层GeoTIFF

开放层GeoTIFF
EN

Stack Overflow用户
提问于 2022-07-15 10:55:51
回答 1查看 131关注 0票数 -1

嗨,有人能解释一下如何使用ol.GeoTIFF层吗?我试过这个教程https://openlayers.org/workshop/en/cog/true-color.html

OL版本: 6.14.1我试图像这样加载该层:

代码语言:javascript
复制
const geoTiffLayer = new ol.layer.WebGLTile({
        id: `geoTiffs`,
        zIndex: 3,
        source: new ol.source.GeoTIFF({
            sources: [
                {
                    url: 'https://sentinel-cogs.s3.us-west-2.amazonaws.com/sentinel-s2-l2a-cogs/21/H/UB/2021/9/S2B_21HUB_20210915_0_L2A/TCI.tif'
                }
            ]
        })
    });

    olMap.addLayer(geoTiffLayer);
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-07-15 13:03:31

如果您使用的是最新的ol.js,并且您的olMap设置正确:

代码语言:javascript
复制
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.14.1/css/ol.css" type="text/css">
    <style>
      .map {
        height: 400px;
        width: 100%;
      }
    </style>
    <script src="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/main/build/ol.js"></script>
  </head>
  <body>
    <div id="map-container" class="map"></div>
    <script type="text/javascript">

      const projection = new ol.proj.Projection({
        code: 'EPSG:32721',
        units: 'm',
      });
      const sourceExtent = [300000, 6090260, 409760, 6200020];
      const olMap = new ol.Map({
        target: 'map-container',
        view: new ol.View({
          projection: projection,
          center: ol.extent.getCenter(sourceExtent),
          extent: sourceExtent,
          zoom: 1,
        })
      });

      const geoTiffLayer = new ol.layer.WebGLTile({
        id: `geoTiffs`,
        zIndex: 3,
        source: new ol.source.GeoTIFF({
          sources: [
            {
              url: 'https://sentinel-cogs.s3.us-west-2.amazonaws.com/sentinel-s2-l2a-cogs/21/H/UB/2021/9/S2B_21HUB_20210915_0_L2A/TCI.tif'
            },
          ],
        }),
      });

      olMap.addLayer(geoTiffLayer);

    </script>
  </body>
</html>

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72992919

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档