Skip to content

Instantly share code, notes, and snippets.

@codingmiao
Created June 30, 2017 05:55
Show Gist options
  • Save codingmiao/85bcb9682aa42fe57f1c2ea0b80dd3da to your computer and use it in GitHub Desktop.
Save codingmiao/85bcb9682aa42fe57f1c2ea0b80dd3da to your computer and use it in GitHub Desktop.
openlayers跨域请求 geoserver wms点击
map.on('click', function (evt) {
var viewResolution = (map.getView().getResolution());
var url = pwLayer.getSource().getGetFeatureInfoUrl(
evt.coordinate,
viewResolution,
'EPSG:4326',
{'INFO_FORMAT': 'text/javascript'});
$.ajax({
url: url,
data: "",
dataType: "jsonp",
jsonpCallback:'parseResponse',
success: function (data) {
console.log(data);
},
error: function () {
console.log("选取设备异常!");
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment