首页 / 浏览问题 / WebGIS / 问题详情
无法获取服务当中的某一座桥梁,某一条隧道啊
22EXP 2023年06月08日
let url =

      "http://10.64.101.123/iserver/services/map-GZGQ-3/rest/maps/zjmaproad";

    this.layerInfoService = new mapboxgl.supermap.LayerInfoService(url);

    this.layerInfoService.getLayersInfo((result) => {

      if (result.result.subLayers.layers) {

        var layers1 = result.result.subLayers.layers;

        for (var i = 0; i < layers1.length; i++) {

          this.list1.push(layers1[i].name);

        }

      }

    });

 var index = this.strArr.indexOf(vals);

      if (index > -1) {

        this.strArr.splice(index, 1); //存在就删除//删除

      } else {

        this.strArr.push(vals);

      }

      const res2 = this.list1.filter(

        (item1) =>

          !this.strArr

            .toString()

            .split(",")

            .some((item2) => item2 === item1)

      );

      this.list2 = [];

      this.strArr

        .toString()

        .split(",")

        .forEach((item) => {

          this.list2.push(

            new SuperMap.LayerStatus({

              layerName: item,

              isVisible: "true",

            })

          );

        });

      res2.forEach((item) => {

        this.list2.push(

          new SuperMap.LayerStatus({

            layerName: item,

            isVisible: "false",

          })

        );

      });

      var p = new SuperMap.SetLayerStatusParameters({

        layerStatusList: this.list2,

      });

      this.layerInfoService.setLayerStatus(p, (e) => {

        if (e.result) {

          var t1 = e.result.newResourceID;

          if (this.map.getLayer("simple-tiles")) {

            this.map.removeLayer("simple-tiles");

            this.map.removeSource("firstLayer");

          }

          this.map.addSource("firstLayer", {

            type: "raster",

            tiles: [

              "http://10.64.101.123/iserver/services/map-GZGQ-3/rest/maps/zjmaproad/zxyTileImage.png?prjCoordSys=" +

                encodeURIComponent('{"epsgCode":3857}') +

                "&z={z}&x={x}&y={y}&noWrap=true&transparent=true&cacheEnabled=false&layersID=" +

                t1,

            ],

            tileSize: 256,

          });

          this.map.addLayer({

            id: "simple-tiles",

            type: "raster",

            source: "firstLayer",

            minzoom: 0,

            maxzoom: 22,

          });

          this.map.on("click", (e) => {

            console.log(e.features, "e.features++e.features", e);

            var features = this.map.queryRenderedFeatures(e.point, {

              layers: ["simple-tiles"],

            });

            console.log(features, "features");

            if (features.length > 0) {

              console.log(features[0].properties, "11111111111");

            }

          });

        }

      });

如何获取服务当中具体的某一座桥梁,某一条隧道啊

1个回答

您好,请问发布的是什么服务,在哪一个地图上加载?
1,865EXP 2023年06月08日
rest,feature服务,加载在二维的mapboxgl上面
怎么处理啊,大哥

如果是想对发布的rest服务进行图层查询,可以通过sql查询,根据数据集名称或者图层名称,添加属性过滤条件构造查询参数QueryBySQLParameters,调用queryBySQL接口。

参考官网示例:https://iclient.supermap.io/examples/mapboxgl/editor.html#01_mapQueryBySQL

技术博客:https://blog.csdn.net/supermapsupport/article/details/53910299

我需要一个有一个的点击事件来获取啊,我看这个也不是点击事件怎么获取啊
如果是通过点击事件获取服务中某一个具体的图层(数据),请问是想获取到数据的属性信息吗?可以通过点击事件获取到地图要素的id,再通过sql查询可以获取到对应数据的属性信息。
...