Leaflet GetFeatureInfo Request with JSONP

by Thomas B.

HTML

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.js"></script>
<div id="map"></div>
<br />
<b>GetFeatureInfo-Request with Ajax and JSONP. Datasource from: <a href="http://www.dartmoor.gov.uk" target="_blank">http://www.dartmoor.gov.uk/</a> </b>
<p>
Have a look at the output of console.log to see the response of the GetFeatureInfo Request...
</p>

JavaScript

// getFeature-Function (static URL for testing)


//var wmsURL_gen = 'http://maps.dartmoor.gov.uk/geoserver/wms?version=1.1.1&REQUEST=GetFeatureInfo&layers=general:tpo_points&BBOX='+BBOX+'&FEATURE_COUNT=5&outputFormat=text/javascript&HEIGHT='+HEIGHT+'&WIDTH='+WIDTH+'&query_layers=general:tpo_points&SRS=EPSG:4326&X='+X+'&Y='+Y+'&format_options=callback:getJson';

var wmsURL='http://belstone.nationalparks.gov.uk/geoserver/general/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetFeatureInfo&QUERY_LAYERS=general:tpo_points&LAYERS=general:tpo_points&INFO_FORMAT=text/javascript&FEATURE_COUNT=5&X=50&Y=50&SRS=EPSG:27700&WIDTH=101&HEIGHT=101&BBOX=269291.6026625545,66769.35257397332,277003.10021540907,74480.85012682788&format_options=callback:getJson'

    
    $.ajax({
    jsonp : false,
    url: wmsURL,
    dataType: 'jsonp',
   jsonpCallback: 'getJson',
    success: handleJson_featureRequest
});
    
function handleJson_featureRequest (data) {
console.log("GetFeatureInfo-Request: ");
console.log(data);
}