许可优化
许可优化
产品
产品
解决方案
解决方案
服务支持
服务支持
关于
关于
软件库
当前位置:服务支持 >  软件文章 >  esri-loader加载ArcGIS地图:从入门到实践

esri-loader加载ArcGIS地图:从入门到实践

阅读数 19
点赞 0
article_banner

在这里插入图片描述

html

<div id="mapDiv"></div>

加载地图

  import {
   
   
    loadModules
  } from "esri-loader";
   data() {
   
   
      return {
   
   
        // 地图类
        map: {
   
   },
        // 地图视图
        view: {
   
   },
        // esri返回值
        ArcGISApi: {
   
   },
        // esri组件
         modules: [
          "esri/config",
          "esri/Map",
          "esri/WebMap",
          "esri/widgets/Locate",
          "esri/widgets/Track",
          "esri/layers/TileLayer",
          "esri/views/MapView",
          "esri/widgets/Locate",
          "esri/widgets/Track",
          "esri/Graphic",
          "esri/widgets/Zoom",
          "esri/geometry/Polygon",
          "esri/geometry/SpatialReference",
          "esri/layers/GraphicsLayer",
          "esri/layers/FeatureLayer",
          "esri/layers/VectorTileLayer",
          "esri/PopupTemplate",
          "esri/widgets/Popup",
          "esri/widgets/Sketch",
          "esri/widgets/Legend",
          "esri/symbols/TextSymbol",
          "esri/symbols/Font",
          "dojo/domReady!",

        ],
        graphicsLayers: {
   
   
          testGraphicsLayer: null,
        },
      };
    },
     mounted() {
   
   
      loadModules(this.modules, {
   
   
        css: true
      }).then(this.initMap);
    },
    methods: {
   
   
     initMap(args) {
   
   
        for (let k in args) {
   
   
          let name = this.modules[k].split("/").pop();
          name = name.replace(name[0], name[0].toUpperCase());
          this.ArcGISApi[name] = args[k];
        }
        var TileLayer = new this.ArcGISApi.TileLayer({
   
   
          url: "https://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineStreetGray/MapServer",
          id: "streets",
        });
        this.map = new this.ArcGISApi.Map({
   
   
          // 底图的图层
          layers: [TileLayer],
        });
        this.view = new this.ArcGISApi.MapView({
   
   
          map: this.map,
          container: "mapDiv",
          zoom: 12,
          center: [116.19432, 39.911222],
        });
       }
   }

添加marker点及文字标注

 // marker样式
 let pictureMarkerSymbol = {
   
   
          type: 'picture-marker',
          url: require('@/assets/img/marker_1.png'),
          width: 8,
          height: 12,
          angle: 90
        }
  // 标注样式
 let textSymbol = {
   
   
          type: "text", // autocasts as new TextSymbol()
          color: "black",
          // haloColor: "black",
          // haloSize: "1px",
          text: "嫩江",
          xoffset: 16,
          yoffset: 6,
          font: {
   
    // autocasts as new Font()
            size: 10,
            family: "sans-serif",
            weight: "normal"
          }
        };
  const point = {
   
   
          //Create a point
          type: "point",
          longitude: 116.3,
          latitude: 39.9,
        };
 //绘画marker图形
const pointGraphic = new this.ArcGISApi.Graphic({
   
   
          geometry: point,
          symbol: pictureMarkerSymbol,
          attributes: {
   
   
            name: "测试",
            des: "这是一个marker点",
          },
        });
  //绘画标识图形
  const pointGraphicText = new this.ArcGISApi.Graphic({
   
   
          geometry: point,
          symbol: textSymbol,
        });
  // 创建图层
 let graphicsLayer = new this.ArcGISApi.GraphicsLayer({
   
   
          id: "001",
          title: "markerLayer",
          graphics: [pointGraphic]
        });
 //将图形添加到图层中
   // graphicsLayer.add(pointGraphicText);
   graphicsLayer.graphics.add(pointGraphicText);
 //将图层添加map中
   this.map.layers.add(graphicsLayer);

获得marker点点击 事件

let that = this;
        this.view.on("click", function (event) {
   
   
          that.view.hitTest(event.screenPoint).then((responses) => {
   
   
            if (responses.results.length > 0) {
   
   
             // marker graphic的attributes 
              const data = responses.results[0].graphic.attributes;
              console.log("markerData", data);
            }
          });
        });

添加 删除图层

在这里插入图片描述

//使用数组在地图的构造函数中添加图层
let fl = new FeatureLayer(url);
let gl = new GraphicsLayer();
let map = new Map({
   
   
  layers: [fl, gl]

免责声明:本文系网络转载或改编,未找到原创作者,版权归原作者所有。如涉及版权,请联系删


相关文章
技术文档
QR Code
微信扫一扫,欢迎咨询~
customer

online

联系我们
武汉格发信息技术有限公司
湖北省武汉市经开区科技园西路6号103孵化器
电话:155-2731-8020 座机:027-59821821
邮件:tanzw@gofarlic.com
Copyright © 2023 Gofarsoft Co.,Ltd. 保留所有权利
遇到许可问题?该如何解决!?
评估许可证实际采购量? 
不清楚软件许可证使用数据? 
收到软件厂商律师函!?  
想要少购买点许可证,节省费用? 
收到软件厂商侵权通告!?  
有正版license,但许可证不够用,需要新购? 
联系方式 board-phone 155-2731-8020
close1
预留信息,一起解决您的问题
* 姓名:
* 手机:

* 公司名称:

姓名不为空

姓名不为空

姓名不为空
手机不正确

手机不正确

手机不正确
公司不为空

公司不为空

公司不为空