arcgis地图定位并高亮显示

拿到矢量坐标数组,可以通过geoserver发布的图层数据,比如geojson
// 这里的result就是矢量数组

 goto(result, name) {

      // console.log(result, name);

      result.forEach((item) => {

        if (item.properties.Name === name) {

        // 要定位的位置的坐标集合

          const coordinates = item.geometry.coordinates[0];

          // console.log("coordinates", coordinates);

          // 通过geometry.coordinates绘制,在地图上高亮显示

          let options = {

            url: "https://js.arcgis.com/4.26/",

            css: "https://js.arcgis.com/4.26/esri/themes/light/main.css",

          };

          loadModules(

            ["esri/Graphic", "esri/layers/GraphicsLayer"],

            options

          ).then(([Graphic, GraphicsLayer]) => {

            this.clearLayerTemporarily();

            const graphicsLayer = new GraphicsLayer();

            this.map.add(graphicsLayer);

            const polyline = {

              type: "polyline",

              paths: [coordinates],

            };

            const simpleFillSymbol = {

              type: "simple-fill",

              color: [255, 255, 255, 0],

              outline: {

                color: [0, 255, 255],

                width: 2,

              },

            };

            const polylineGraphic = new Graphic({

              geometry: polyline,

              symbol: simpleFillSymbol,

            });

            graphicsLayer.add(polylineGraphic);

            // 临时图层

            this.layer_temporarily = graphicsLayer;

            this.layer_temporarily_list.push(graphicsLayer);

          });

        // 计算中心点

          var x = 0,

            y = 0;

          coordinates.forEach((item) => {

            x += item[0];

            y += item[1];

          });

        // 跳转

          this.view.goTo({

            target: [

              parseFloat(x / coordinates.length),

              parseFloat(y / coordinates.length),

            ],

            heading: 180,

            duration: 2000,

          });

        }

      });

    },

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值