<html lang="en">

 <head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>demo</title>
<style> </style> </head> <body>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script type="text/javascript" src="jquery.xml2json.js"></script>
<script>
$.ajax({
url: "http://127.0.0.1:6080/arcgis/services/Mymap/MapServer/WMSServer",
data: {
version: '1.3.0',
request: 'getfeatureinfo',
layers: '0',
styles: '',
CRS: 'EPSG:4326',
bbox: '28.123462,120.123272,29.481238,120.123941',//xmin,ymin,xmax,ymax
width: '1730',
height: '919',
info_format: 'text/xml',
x: '760',
y: '229',
query_layers: "0"
},
dataType: 'xml',
success: function(data) {
console.log(data);
},
error: function(e) {
console.log(e);
} });
</script>
</body> </html>
 /*
### jQuery XML to JSON Plugin v1.3 - 2013-02-18 ###
* http://www.fyneworks.com/ - diego@fyneworks.com
* Licensed under http://en.wikipedia.org/wiki/MIT_License
###
Website: http://www.fyneworks.com/jquery/xml-to-json/
*/
/*
# INSPIRED BY: http://www.terracoder.com/
AND: http://www.thomasfrank.se/xml_to_json.html
AND: http://www.kawa.net/works/js/xml/objtree-e.html
*/
/*
This simple script converts XML (document of code) into a JSON object. It is the combination of 2
'xml to json' great parsers (see below) which allows for both 'simple' and 'extended' parsing modes.
*/
// Avoid collisions
;
if (window.jQuery)(function($) { // Add function to jQuery namespace
$.extend({ // converts xml documents and xml text to json object
xml2json: function(xml, extended) {
if (!xml) return {}; // quick fail //### PARSER LIBRARY
// Core function
function parseXML(node, simple) {
if (!node) return null;
var txt = '',
obj = null,
att = null;
var nt = node.nodeType,
nn = jsVar(node.localName || node.nodeName);
var nv = node.text || node.nodeValue || '';
/*DBG*/ //if(window.console) console.log(['x2j',nn,nt,nv.length+' bytes']);
if (node.childNodes) {
if (node.childNodes.length > 0) {
/*DBG*/ //if(window.console) console.log(['x2j',nn,'CHILDREN',node.childNodes]);
$.each(node.childNodes, function(n, cn) {
var cnt = cn.nodeType,
cnn = jsVar(cn.localName || cn.nodeName);
var cnv = cn.text || cn.nodeValue || '';
/*DBG*/ //if(window.console) console.log(['x2j',nn,'node>a',cnn,cnt,cnv]);
if (cnt == 8) {
/*DBG*/ //if(window.console) console.log(['x2j',nn,'node>b',cnn,'COMMENT (ignore)']);
return; // ignore comment node
} else if (cnt == 3 || cnt == 4 || !cnn) {
// ignore white-space in between tags
if (cnv.match(/^\s+$/)) {
/*DBG*/ //if(window.console) console.log(['x2j',nn,'node>c',cnn,'WHITE-SPACE (ignore)']);
return;
};
/*DBG*/ //if(window.console) console.log(['x2j',nn,'node>d',cnn,'TEXT']);
txt += cnv.replace(/^\s+/, '').replace(/\s+$/, '');
// make sure we ditch trailing spaces from markup
} else {
/*DBG*/ //if(window.console) console.log(['x2j',nn,'node>e',cnn,'OBJECT']);
obj = obj || {};
if (obj[cnn]) {
/*DBG*/ //if(window.console) console.log(['x2j',nn,'node>f',cnn,'ARRAY']); // http://forum.jquery.com/topic/jquery-jquery-xml2json-problems-when-siblings-of-the-same-tagname-only-have-a-textnode-as-a-child
if (!obj[cnn].length) obj[cnn] = myArr(obj[cnn]);
obj[cnn] = myArr(obj[cnn]); obj[cnn][obj[cnn].length] = parseXML(cn, true /* simple */ );
obj[cnn].length = obj[cnn].length;
} else {
/*DBG*/ //if(window.console) console.log(['x2j',nn,'node>g',cnn,'dig deeper...']);
obj[cnn] = parseXML(cn);
};
};
});
}; //node.childNodes.length>0
}; //node.childNodes
if (node.attributes) {
if (node.attributes.length > 0) {
/*DBG*/ //if(window.console) console.log(['x2j',nn,'ATTRIBUTES',node.attributes])
att = {};
obj = obj || {};
$.each(node.attributes, function(a, at) {
var atn = jsVar(at.name),
atv = at.value;
att[atn] = atv;
if (obj[atn]) {
/*DBG*/ //if(window.console) console.log(['x2j',nn,'attr>',atn,'ARRAY']); // http://forum.jquery.com/topic/jquery-jquery-xml2json-problems-when-siblings-of-the-same-tagname-only-have-a-textnode-as-a-child
//if(!obj[atn].length) obj[atn] = myArr(obj[atn]);//[ obj[ atn ] ];
obj[cnn] = myArr(obj[cnn]); obj[atn][obj[atn].length] = atv;
obj[atn].length = obj[atn].length;
} else {
/*DBG*/ //if(window.console) console.log(['x2j',nn,'attr>',atn,'TEXT']);
obj[atn] = atv;
};
});
//obj['attributes'] = att;
}; //node.attributes.length>0
}; //node.attributes
if (obj) {
obj = $.extend((txt != '' ? new String(txt) : {}), /* {text:txt},*/ obj || {} /*, att || {}*/ );
//txt = (obj.text) ? (typeof(obj.text)=='object' ? obj.text : [obj.text || '']).concat([txt]) : txt;
txt = (obj.text) ? ([obj.text || '']).concat([txt]) : txt;
if (txt) obj.text = txt;
txt = '';
};
var out = obj || txt;
//console.log([extended, simple, out]);
if (extended) {
if (txt) out = {}; //new String(out);
txt = out.text || txt || '';
if (txt) out.text = txt;
if (!simple) out = myArr(out);
};
return out;
}; // parseXML
// Core Function End
// Utility functions
var jsVar = function(s) { return String(s || '').replace(/-/g, "_"); }; // NEW isNum function: 01/09/2010
// Thanks to Emile Grau, GigaTecnologies S.L., www.gigatransfer.com, www.mygigamail.com
function isNum(s) {
// based on utility function isNum from xml2json plugin (http://www.fyneworks.com/ - diego@fyneworks.com)
// few bugs corrected from original function :
// - syntax error : regexp.test(string) instead of string.test(reg)
// - regexp modified to accept comma as decimal mark (latin syntax : 25,24 )
// - regexp modified to reject if no number before decimal mark : ".7" is not accepted
// - string is "trimmed", allowing to accept space at the beginning and end of string
var regexp = /^((-)?([0-9]+)(([\.\,]{0,1})([0-9]+))?$)/
return (typeof s == "number") || regexp.test(String((s && typeof s == "string") ? jQuery.trim(s) : ''));
};
// OLD isNum function: (for reference only)
//var isNum = function(s){ return (typeof s == "number") || String((s && typeof s == "string") ? s : '').test(/^((-)?([0-9]*)((\.{0,1})([0-9]+))?$)/); }; var myArr = function(o) { // http://forum.jquery.com/topic/jquery-jquery-xml2json-problems-when-siblings-of-the-same-tagname-only-have-a-textnode-as-a-child
//if(!o.length) o = [ o ]; o.length=o.length;
if (!$.isArray(o)) o = [o];
o.length = o.length; // here is where you can attach additional functionality, such as searching and sorting...
return o;
};
// Utility functions End
//### PARSER LIBRARY END // Convert plain text to xml
if (typeof xml == 'string') xml = $.text2xml(xml); // Quick fail if not xml (or if this is a node)
if (!xml.nodeType) return;
if (xml.nodeType == 3 || xml.nodeType == 4) return xml.nodeValue; // Find xml root node
var root = (xml.nodeType == 9) ? xml.documentElement : xml; // Convert xml to json
var out = parseXML(root, true /* simple */ ); // Clean-up memory
xml = null;
root = null; // Send output
return out;
}, // Convert text to XML DOM
text2xml: function(str) {
// NOTE: I'd like to use jQuery for this, but jQuery makes all tags uppercase
//return $(xml)[0]; /* prior to jquery 1.9 */
/*
var out;
try{
var xml = ((!$.support.opacity && !$.support.style))?new ActiveXObject("Microsoft.XMLDOM"):new DOMParser();
xml.async = false;
}catch(e){ throw new Error("XML Parser could not be instantiated") };
try{
if((!$.support.opacity && !$.support.style)) out = (xml.loadXML(str))?xml:false;
else out = xml.parseFromString(str, "text/xml");
}catch(e){ throw new Error("Error parsing XML string") };
return out;
*/ /* jquery 1.9+ */
return $.parseXML(str);
} }); // extend $ })(jQuery);

我测试的是ArcServer发布的wms服务,geoserver发布的wms服务请自行测试。

附上xml2json代码,感谢原作者xtreemrage,github链接https://github.com/xtreemrage/jquery.xml2json

ajax根据坐标查询WMS地图服务属性信息的更多相关文章

  1. World Wind Java开发之十四——添加WMS地图服务资源(转)

    数据是GIS的核心,没有数据一切无从谈起,Internet上有很多在线WMS地图服务资源,我们可以好好利用这些数据资源,比如天地图.必应地图.NASA.OGC数据服务等等. 在我们国家常用的还是天地图 ...

  2. ArcGIS Server开发实践之【Search Widget工具查询本地地图服务】

    加载本地地图服务,并实现要素的查询.(不足之处还请指点)具体代码如下: <!DOCTYPE html> <html dir="ltr"> <head& ...

  3. SuperMap iClient如何使用WMS地图服务

    什么是WMS服务 WMS(Web Map Service,Web 地图服务)服务,该服务符合 OGC(Open Geospatial Consortium,开放地理信息联盟)制定的 WMS 实现规范. ...

  4. 手把手教你怎么用ArcgisOnline发布地图服务

    Arcgis推出了Arcgis Online,但是大家都不知道这是个什么东西,怎么用这个东西,今天这篇文章手把手的教你如何使用Arcgisonline发布地图服务. 一.ArcgisOnline简介 ...

  5. arcgis地图服务之 identify 服务

    arcgis地图服务之 identify 服务 在近期的一次开发过程中,利用IdentityTask工具查询图层的时候,请求的参数中ImageDisplay的参数出现了错误,导致查询直接不能执行,百度 ...

  6. Web地图服务、WMS 请求方式、网络地图服务(WMS)的三大操作

    转自奔跑的熊猫原文 Web地图服务.WMS 请求方式.网络地图服务(WMS)的三大操作 1.GeoServer(地理信息系统服务器) GeoServer是OpenGIS Web 服务器规范的 J2EE ...

  7. WMS、WFS、WCS、WPS、WMTS、WMSC、TMS等常见地图服务的区别

    WebGIS的开发者经常需要面对各种地图服务规范,例如WMS.WFS.WCS.WPS.WMTS.TMS.WMSC等.因此了解这些服务的内容是相当重要的,这里对常见的服务进行了整理. OGC联盟: 开放 ...

  8. 常见地图服务(WMS、WFS、WCS、TMS、WMTS

    1.网络地图服务(WMS) 网络地图服务(WMS)利用具有地理空间位置信息的数据制作地图.其中将地图定义为地理数据可视的表现.能够根据用户的请求返回相应的地图(包括PNG,GIF,JPEG等栅格形式或 ...

  9. wms、wmts、wfs等地图服务区别

    OGC     OGC 全称是开放地理空间信息联盟(Open Geospatial Consortium),是一个非盈利的国际标准组织,它制定了数据和服务的一系列标准,GIS厂商按照这个标准进行开发可 ...

随机推荐

  1. .Net Core微服务入门全纪录(四)——Ocelot-API网关(上)

    前言 上一篇[.Net Core微服务入门全纪录(三)--Consul-服务注册与发现(下)]已经使用Consul完成了服务的注册与发现,实际中光有服务注册与发现往往是不够的,我们需要一个统一的入口来 ...

  2. 一篇文章教会你使用Python定时抓取微博评论

    [Part1--理论篇] 试想一个问题,如果我们要抓取某个微博大V微博的评论数据,应该怎么实现呢?最简单的做法就是找到微博评论数据接口,然后通过改变参数来获取最新数据并保存.首先从微博api寻找抓取评 ...

  3. 03.DRF-设计方法

    RESTful设计方法 1. 域名 应该尽量将API部署在专用域名之下. https://api.example.com 如果确定API很简单,不会有进一步扩展,可以考虑放在主域名下. https:/ ...

  4. TopK问题,数组中第K大(小)个元素问题总结

    问题描述: 在未排序的数组中找到第 k 个最大的元素.请注意,你需要找的是数组排序后的第 k 个最大的元素,而不是第 k 个不同的元素. 面试中常考的问题之一,同时这道题由于解法众多,也是考察时间复杂 ...

  5. Asp.Net 五大对象及作用

    Connection(连接对象):与数据源建立连接. DataAdapter(适配器对象):对数据源执行操作并返回结果,在DataSet与数据源之间建立通信,将数据源中的数据写入DataSet中,或根 ...

  6. 使用json-server与Mockjs搭建模拟服务

    为什么使用 在项目开发中,常常需要边写前端页面边写后端接口,但是后端接口服务往往是滞后于前端开发的,或者是不能及时提供的.出于前端开发的迅速和便捷去考虑,我们可以根据后端接口数据结构去模拟(mock) ...

  7. 动态自动配置Bean

    概览 接口Condition 用于基于条件的自动配置,和注解@Conditional配合使用,可实现JavaBean的动态自动配置 自定义实现动态配置Bean 定义一个接口和两个实现类 定义两个Con ...

  8. JasperReport报表中输出Excel时,部分列不显示的问题

    JasperReport开源报表功能强大,是我们WEB系统中做报表开发的一个强有力的工具,上手也比较简单.我碰到的问题是进行报表输出时,在html网页中显示正常,但如果导出为Excel时,部分列不显示 ...

  9. java语言进阶(七)_Lambda表达式

    1 函数式编程思想概述 在数学中,函数就是有输入量.输出量的一套计算方案,也就是"拿什么东西做什么事情".相对而言,面向对象过分强调"必须通过对象的形式来做事情" ...

  10. css如何设置不可点击?

    通过设置元素的pointer-events属性设置为none,来实现元素不可点击.此方法是通过设置元素的鼠标事件失效来实现元素不可点击. css设置不可点击: css代码: .disable { po ...