Geoserver & Leaflet GetFeatureInfo(特征信息)

问题描述 投票:0回答:1

我想在点击WMS层外的时候,禁用Leaflet的WMS getFeatureInfo弹出窗口。请在此输入图片描述 我使用这个插件 https:/gist.github.comrclark6908938

javascript leaflet geoserver wms
1个回答
0
投票

把你的功能改成

 getFeatureInfo: function (evt) {
    // Make an AJAX request to the server and hope for the best
    var url = this.getFeatureInfoUrl(evt.latlng),
      showResults = L.Util.bind(this.showGetFeatureInfo, this);
    $.ajax({
      url: url,
      success: function (data, status, xhr) {
        var err = typeof data === 'string' ? null : data;
        //Fix for blank popup window
        var doc = (new DOMParser()).parseFromString(data, "text/html"); 
        if (doc.body.innerHTML.trim().length > 0)
          showResults(err, evt.latlng, data);
      },
      error: function (xhr, status, error) {
        showResults(error);
      }
    });
  },

来源: https:/gist.github.comrclark6908938#gistcomment-2277325

© www.soinside.com 2019 - 2024. All rights reserved.