ArcGIS JS API4.24 带你风云变幻

js api4.24现在支持视频图层,这样我们就可以将视频投影到地图上,这样比如气象中的一些风云动画图效果就出来了

image.png

视频如下:
链接:https://pan.baidu.com/s/1M9CiqxvDEBU6dYso3pFsIA?pwd=f8jf
提取码:f8jf
--来自百度网盘超级会员V7的分享
目前限制:
只能在地表水进行显示,不能显示在倾斜、3d图层上
代码如下:

<html>
  <head>
    <meta charset="utf-8" />
    <meta
      name="viewport"
      content="initial-scale=1,maximum-scale=1,user-scalable=no"
    />
    <title>
      Custom ElevationLayer - Exaggerating elevation | Sample | ArcGIS API for
      JavaScript 4.24
    </title>

    <link
      rel="stylesheet"
      href="https://js.arcgis.com/4.24/esri/themes/light/main.css"
    />

    <script src="https://js.arcgis.com/4.24/"></script>

    <script>
      require([
        "esri/Map",
        "esri/views/SceneView",
        "esri/layers/ElevationLayer",
        "esri/layers/BaseElevationLayer",
        "esri/layers/MediaLayer",
        "esri/layers/support/VideoElement",
        "esri/layers/support/ExtentAndRotationGeoreference",
           "esri/geometry/Extent",
        "esri/Basemap",
        "esri/layers/TileLayer"
      ], (
        Map,
        SceneView,
        ElevationLayer,
        BaseElevationLayer,
        MediaLayer,
        VideoElement,
        ExtentAndRotationGeoreference,
        Extent,
        Basemap,
        TileLayer
      ) => {
        //////////////////////////////////////////////
        //
        //   Create a subclass of BaseElevationLayer
        //
        /////////////////////////////////////////////

        const ExaggeratedElevationLayer = BaseElevationLayer.createSubclass({
          // Add an exaggeration property whose value will be used
          // to multiply the elevations at each tile by a specified
          // factor. In this case terrain will render 100x the actual elevation.

          properties: {
            exaggeration: 70
          },

          // The load() method is called when the layer is added to the map
          // prior to it being rendered in the view.
          load: function () {
            // TopoBathy3D contains elevation values for both land and ocean ground
            this._elevation = new ElevationLayer({
              url: "https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/TopoBathy3D/ImageServer"
            });

            // wait for the elevation layer to load before resolving load()
            this.addResolvingPromise(
              this._elevation.load().then(() => {
                // get tileInfo, spatialReference and fullExtent from the elevation service
                // this is required for elevation services with a custom spatialReference
                this.tileInfo = this._elevation.tileInfo;
                this.spatialReference = this._elevation.spatialReference;
                this.fullExtent = this._elevation.fullExtent;
              })
            );

            return this;
          },

          // Fetches the tile(s) visible in the view
          fetchTile: function (level, row, col, options) {
            // calls fetchTile() on the elevationlayer for the tiles
            // visible in the view
            return this._elevation.fetchTile(level, row, col, options).then(
              function (data) {
                const exaggeration = this.exaggeration;
                // `data` is an object that contains the
                // the width and the height of the tile in pixels,
                // and the values of each pixel
                for (let i = 0; i < data.values.length; i++) {
                  // Multiply the given pixel value
                  // by the exaggeration value
                  data.values[i] = data.values[i] * exaggeration;
                }

                return data;
              }.bind(this)
            );
          }
        });

        const basemap = new Basemap({
          baseLayers: [
            new TileLayer({
              url: "https://tiles.arcgis.com/tiles/nGt4QxSblgDfeJn9/arcgis/rest/services/terrain_with_heavy_bathymetry/MapServer",
              copyright:
                'Bathymetry, topography and satellite imagery from <a href="https://visibleearth.nasa.gov/view_cat.php?categoryID=1484" target="_blank">NASA Visible Earth</a> | <a href="http://www.aag.org/global_ecosystems" target="_blank">World Ecological Land Units, AAG</a> | Oceans, glaciers and water bodies from <a href="https://www.naturalearthdata.com/" target="_blank">Natural Earth</a>'
            })
          ]
        });

        const elevationLayer = new ExaggeratedElevationLayer();
        const element = new VideoElement({
          video:
            "https://arcgis.github.io/arcgis-samples-javascript/sample-data/media-layer/videos/hurricanes_aerosol-aug.mp4",
          georeference: new ExtentAndRotationGeoreference({
            extent: new Extent({
              xmin: -150,
              ymin: 1,
              xmax: 20,
              ymax: 80,
              spatialReference: {
                wkid: 4326
              }
            })
          })
        });
        const layer = new MediaLayer({
          source: [element],
          title: "2017 Hurricanes and Aerosols Simulation",
          copyright: "NASA's Goddard Space Flight Center"
        });
        
        // Add the exaggerated elevation layer to the map's ground
        // in place of the default world elevation service
        const map = new Map({
          basemap: "satellite",
          ground: {
            layers: [elevationLayer]
          }
        });
        map.add(layer);

        const view = new SceneView({
          container: "viewDiv",
          map: map,
          alphaCompositingEnabled: true,
          qualityProfile: "high",
          camera: {
            position: [-55.039, 14.948, 19921223.3],
            heading: 2.03,
            tilt: 0.13
          },
          environment: {
            background: {
              type: "color",
              color: [255, 252, 244, 0]
            },
            starsEnabled: false,
            atmosphereEnabled: false,
            lighting: {
              type: "virtual"
            }
          },
      
          popup: {
            dockEnabled: true,
            dockOptions: {
              position: "top-right",
              breakpoint: false,
              buttonEnabled: false
            },
            collapseEnabled: false
          },
          highlightOptions: {
            color: [255, 255, 255],
            haloOpacity: 0.5
          }
        });

        let exaggerated = true;

        document
          .getElementById("exaggerate")
          .addEventListener("click", (event) => {
            if (exaggerated) {
              map.ground = "world-elevation";
              event.target.innerHTML = "Enable exaggeration";
              exaggerated = false;
            } else {
              map.ground = {
                layers: [elevationLayer]
              };
              event.target.innerHTML = "Disable exaggeration";
              exaggerated = true;
            }
          });
      });
    </script>
    <style>
      html,
      body,
      #viewDiv {
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
      }

      body {
        background: radial-gradient(#12bff2, #0269a1);
      }

      #viewDiv canvas {
        filter: saturate(1.2) drop-shadow(0 0 20px white);
      }

      .buttons {
        position: absolute;
        bottom: 20px;
        left: 0;
        right: 0;
        text-align: center;
      }

      .esri-button {
        display: inline;
        max-width: 200px;
      }
    </style>
  </head>
  <body>
    <div id="viewDiv"></div>
    <div class="buttons">
      <button id="exaggerate" class="esri-button">Disable exaggeration</button>
    </div>
  </body>
</html>
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 216,496评论 6 501
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,407评论 3 392
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 162,632评论 0 353
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,180评论 1 292
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,198评论 6 388
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,165评论 1 299
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,052评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,910评论 0 274
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,324评论 1 310
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,542评论 2 332
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,711评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,424评论 5 343
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,017评论 3 326
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,668评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,823评论 1 269
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,722评论 2 368
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,611评论 2 353

推荐阅读更多精彩内容