cookicshmily
cookicshmily
采纳率100%
2017-12-05 07:43 阅读 1.8k

怎么通过ajax从wms服务获取属性信息?

代码:

``` var url = "http://*******/arcgis/services/layer/MapServer/WMSServer";
var dat = {
VERSION: "1.3.0", REQUEST: "GetFeatureInfo", QUERY_LAYERS: "topp:states",
BBOX: "*,*,*,*", crs: "4326", INFO_FORMAT: "text/javascript",
I: "200", J: "100", WIDTH: "256", HEIGHT: "256", layers: "topp:states"
}
$.ajax({
type:'GET',
url: url,
data: dat,
success: function (data) {
console.log(data);
},
error: function (errormsg) {
console.log(errormsg);
}
});

但是提示:
Failed to load http://******  No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access.

好像是跨域问题,就采用jsonp跨域,但是返回数据格式错误,提示:
Uncaught SyntaxError: Unexpected token <

主要是想点击wms地图获取属性信息,想请教各位怎么获取wms的属性信息?
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • 已采纳
    xf_turbo xf_turbo 2017-12-11 09:20

    我的跨域是这样的,
    $.ajax({
    type: "POST",
    async: false,
    url: "请求地址",
    data: JSON.stringify({
    "getType": "custregist",
    "Params": JSON.stringify({
    //参数
    })
    }),
    contentType:"application/json",
    success: function (json) {} });

    点赞 1 评论 复制链接分享
  • GISuuser GIS开发者 2018-10-30 03:07

    设置ArcGIS Server允许跨域同样可以解决这个问题

    点赞 评论 复制链接分享

相关推荐