zoukankan      html  css  js  c++  java
  • arcgis api中save map

    保存地图

    需要引入的模块:

    import WebMap from "@arcgis/core/WebMap";

    首先声明一个webmap,引入底图

    const webmap = new WebMap({
      portalItem: { // autocasts as new PortalItem()
        id: "e691172598f04ea8881cd2a4adaa45ba"
      }
    });

    官方使用文档:

    webmap.updateFrom(view)
      .then(function() {
        return webmap.save();
      })
      // thumbnail will be updated based on current extent of webmap
      .then(function(portalItem) {
        console.log("Saved to portal", portalItem.id);
      })
      .catch(function(error) {
        console.error("Error saving to portal", error);
      });

    实际使用过程中,保存之后提示保存结果

    map.updateFrom(view).then(function(){
                  map.saveAs(item)
                  // Saved successfully
                  .then(function(item) {
                    // 设置存储位置
                    var itemPageUrl = item.portal.url + "/home/item.html?id=" + item.id;
                    var link = '<a target="_blank" href="' + itemPageUrl + '">' + title.value + </a>";
    //弹窗提示成功信息,并给出存储链接
                    statusMessage("Save WebMap", "<br>Successfully saved as <i>"+link + </i>"
                    );
                  })
                  // Save didn't work correctly
                  .catch(function(error) {
    //弹窗提示错误信息
                    statusMessage("Save WebMap", "<br> Error " + error);
                  });
                });

    保存三维地图:

    // Update properties of the WebScene related to the view.
                // This should be called just before saving a webscene.
                scene.updateFrom(view).then(() => {
                  scene
                    .saveAs(item)
                    // Saved successfully
                    .then((item) => {
                      // link to the newly-created web scene item
                      const itemPageUrl = item.portal.url + "/home/item.html?id=" + item.id;
                      const link = '<a target="_blank" href="' + itemPageUrl + '">' + title.value + "</a>";
    
                      statusMessage("Save WebScene", "<br> Successfully saved as <i>" + link + "</i>");
                    })
                    // Save didn't work correctly
                    .catch((error) => {
                      statusMessage("Save WebScene", "<br> Error " + error);
                    });
                });

    webmap.updateFrom(view)

      .then(function() {

        return webmap.save();

      })

      // thumbnail will be updated based on current extent of webmap

      .then(function(portalItem) {

        console.log("Saved to portal", portalItem.id);

      })

      .catch(function(error) {

        console.error("Error saving to portal", error);

      });

  • 相关阅读:
    HDU 2433 Travel (最短路,BFS,变形)
    HDU 2544 最短路 (最短路,spfa)
    HDU 2063 过山车 (最大匹配,匈牙利算法)
    HDU 1150 Machine Schedule (最小覆盖,匈牙利算法)
    290 Word Pattern 单词模式
    289 Game of Life 生命的游戏
    287 Find the Duplicate Number 寻找重复数
    283 Move Zeroes 移动零
    282 Expression Add Operators 给表达式添加运算符
    279 Perfect Squares 完美平方数
  • 原文地址:https://www.cnblogs.com/1gaoyu/p/15167606.html
Copyright © 2011-2022 走看看