Yes, see this answer: https://gis.stackexchange.com/a/211562/3399
This is the JavaScript implementation:
var parameters = {
service: 'WMS',
version: '1.1.1',
request: 'GetFeatureInfo',
layers: currentLayer,
query_layers: currentLayer,
feature_count: 10,
info_format: 'text/javascript',
format_options: 'callback:handleJson',
SrsName: 'EPSG:4326',
width: 101,
height: 101,
x: 50,
y: 50,
bbox: (lng - 0.1) + ',' + (lat - 0.1) + ',' + (lng + 0.1) + ',' + (lat + 0.1)
}
var url = owsurl + L.Util.getParamString(parameters)
$.ajax({
url: owsurl + L.Util.getParamString(parameters),
dataType: 'jsonp',
success: function (data) {
handleJson(data)
}
})
Basically, you use the lat, lon to create a bounding box, and select the values in the middle of it. You can return JSON, which you can eat up with your code.
There is an example on the page you link to, all you need to do is remove the lines that print the geometry. (<#--
starts a comment, -->
ends it)
<#list features as feature>
{
"content" : "this is the content",
"type": "Feature",
"id" : "${feature.fid}",
<#list feature.attributes as attribute>
<#if attribute.isGeometry>
<#-- "geometry": ${geoJSON.geomToGeoJSON(attribute.rawValue)}, -->
</#if>
</#list>
"properties": {
<#list feature.attributes?filter(a -> !a.isGeometry) as attribute>
"${attribute.name}": "${attribute.value}"
<#if attribute_has_next>
,
</#if>
</#list>
}
}
<#if feature_has_next>
,
</#if>
</#list>
Best Answer
That's an artefact of the way the JSON code loops over the attributes, however since you are expected to do something with the returned JSON it doesn't really matter what order it is returned in.
If it is absolutely essential to have a fixed order (i.e. you have a very dumb client) then you can write a FreeMarker template to enforce it.