来自WMS 1.1.1 GetFeatureInfo的Dojo请求

时间:2017-01-04 09:48:30

标签: javascript dojo httprequest wms getfeatureinfo

我正在尝试从样本WMS的GetFeatureInfo获取响应。但是得到 “无法加载http://ogi.state.ok.us/geoserver/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetFeatureInfo&SRS=EPSG:4326&BBOX=-104.5005,32.7501,-94.01,37.20&WIDTH=800&HEIGHT=300&LAYERS=ogi:okcounties&QUERY_LAYERS=ogi:okcounties&STYLES=&X=550&Y=105&状态:0”

var httpurl = "http://ogi.state.ok.us/geoserver/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetFeatureInfo&SRS=EPSG:4326&BBOX=-104.5005,32.7501,-94.01,37.20&WIDTH=800&HEIGHT=300&LAYERS=ogi:okcounties&QUERY_LAYERS=ogi:okcounties&STYLES=&X=550&Y=105&";              
try {
              require(["dojo/request"], function (request) {
                  var promise = request(httpurl);

                  promise.response.then(
                      function (response) {
                          var kk = response;
                      },
                      function (error) {
                          var kk = error;
                      }
                  );
              });
          } catch (ex) {
              alert(ex.message);
          }

1 个答案:

答案 0 :(得分:0)

我发现了一些潜在的问题:

  1. 根据request documentation,我认为您应该直接致电.then()。 Lke this:

    promise.then(...);

  2. 就在这一行:var kk = data; ...您正在使用变量data,但您应该使用response

  3. 您可能遇到了CORS问题 - 您的代码是否与该网址在同一个域中运行?如果没有,并且网站所有者不想为您的域启用CORS,您可能需要运行CORS代理(google it)

相关问题