geoserver服务点击某一元素显示高亮

geoserver服务点击某一元素显示高亮

针对vue结合openlayers的使用点击geoserver显示弹框文章中显示高亮的优化,弹框popup待优化
let self_map = this.map;
        self_map.on("singleclick", function(evt) {
        //点击只一个元素高亮
          if (this._wfs_layer_) {
            self_map.removeLayer(this._wfs_layer_);
          }
          let view = self_map.getView();
          let viewResolution = view.getResolution();
          let clicks = [];
          self_map.forEachLayerAtPixel(evt.pixel, function(l, b) {
            if (l.get("click") && l.getVisible()) {
              clicks.push(l);
            }
          });
          try {
            var l = clicks.shift();
            var url = l
              .getSource()
              .getFeatureInfoUrl(
                evt.coordinate,
                viewResolution,
                view.getProjection(), {
                  INFO_FORMAT: "application/json",
                }
              );
            axios(url).then(res => {
              console.log(res)
              let feature = new GeoJSON().readFeature(
                res.data.features[0].geometry
              );
              //创建矢量图层点击样式
              _wfs_source = new VectorSource();
              this._wfs_layer_ = new VectorLayer({
                source: _wfs_source,
                style: new Style({
                  fill: new Fill({
                    //填充样式
                    color: "rgba(255, 255, 255, 0.2)",
                  }),
                  stroke: new Stroke({
                    //线样式
                    color: "#0099FF",
                    width: 3,
                  }),
                }),
                visible: true,
                code: true,
                zIndex: 50,
              });
              self_map.addLayer(this._wfs_layer_);
              _wfs_source.addFeature(feature);
            })
          } catch (e) {
            console.log("未点到数据");
            //TODO handle the exception
          }
        })
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值