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

      });

  • 相关阅读:
    lsblk命令详解
    lspci命令详解
    numastat命令详解
    lsscsi命令详解
    lscpu命令详解
    linux内核模块相关命令:lsmod,depmod,modprobe,modinfo,insmod,rmmod 使用说明
    elk收集tomcat的日志
    npm安装
    centos7.5 解决缺少libstdc++.so.6库的原因及解决办法
    linux下正确卸载rpm包
  • 原文地址:https://www.cnblogs.com/1gaoyu/p/15167606.html
Copyright © 2011-2022 走看看