OpenLayer 3 中是否有 GeoTIFF 的实现?

huangapple go评论44阅读模式
英文:

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 -->

&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot;&gt;
  &lt;head&gt;
    &lt;meta charset=&quot;UTF-8&quot;&gt;
    &lt;title&gt;Cloud Optimized GeoTIFF (COG)&lt;/title&gt;
    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/ol@v7.3.0/ol.css&quot;&gt;
    &lt;style&gt;
      html, body, .map {
        margin: 0;
        padding: 0;
        width: 100%;
        height: 100%;
      }
    &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;div id=&quot;map&quot; class=&quot;map&quot;&gt;&lt;/div&gt;
    &lt;script src=&quot;https://cdn.jsdelivr.net/npm/elm-pep@1.0.6/dist/elm-pep.js&quot;&gt;&lt;/script&gt;
    &lt;script src=&quot;https://cdn.jsdelivr.net/npm/geotiff&quot;&gt;&lt;/script&gt;
    &lt;script src=&quot;https://cdn.jsdelivr.net/npm/ol@v7.3.0/dist/ol.js&quot;&gt;&lt;/script&gt;
    &lt;script&gt;

const source = new ol.source.GeoTIFF({
  sources: [
    {
      url: &#39;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&#39;,
    },
  ],
});

const map = new ol.Map({
  target: &#39;map&#39;,
  layers: [
    new ol.layer.WebGLTile({
      source: source,
    }),
  ],
  view: source.getView(),
});

    &lt;/script&gt;
  &lt;/body&gt;
&lt;/html&gt;

<!-- end snippet -->

huangapple
  • 本文由 发表于 2023年3月7日 23:05:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/75663696.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定