function getDemInfo(geomObj,map){
var point = new ol.geom.Point(ol.proj.fromLonLat([94.085 ,42.118]));
point = [94.085 ,42.118];
let offset = 0.00001;
let minx = point[0] - offset;
let miny = point[1] - offset;
let maxx = point[0] + offset;
let maxy = point[1] + offset;
let url = "http://192.168.0.164:5081/geoserver/shp/wms"
+ "?SERVICE=WMS"
+ "&VERSION=2.0.0"
+ "&REQUEST=GetFeatureInfo"
+ "&FORMAT=" + encodeURIComponent("image/png")
+ "&TRANSPARENT=true"
+ "&QUERY_LAYERS=" + encodeURIComponent("shp:高程_Level_16")
+ "&LAYERS=" + encodeURIComponent("shp:高程_Level_16")
+ "&exceptions=" + encodeURIComponent("application/vnd.ogc.se_inimage")
+ "&INFO_FORMAT=" + encodeURIComponent("application/json")
+ "&FEATURE_COUNT=50"
+ "&X=50"
+ "&Y=50"
+ "&SRS=EPSG%3A4326"
+ "&STYLES="
+ "&WIDTH=101"
+ "&HEIGHT=101"
+ "&BBOX=" + encodeURIComponent(minx + "," + miny + "," + maxx + "," + maxy);
console.log(url);
fetch(url).then(function(response) {
return response.json();
}).then(function (json) {
console.info(json);
return json;
});
$.getJSON(url, function (data) {
console.log(data);
console.info("海拔高度:"+data.features[0].properties.GRAY_INDEX);
});
}
原文:https://www.cnblogs.com/zt2710/p/14760843.html