I am trying to make an AJAX request from a Leaflet map with Jquery to GeoServer to return a WFS selection using the INTERSECT sql_filter param. I have it working fine using the BBOX sql_filter.
Successful request using BBOX filter
var geojsonLayer = new L.GeoJSON();
var currSelectionLayer = 'DRCOGPUB:rea_drcog_jurisdiction_county';
var sw_lat = 39.93290692296977;
var sw_long = -105.39459228515624;
var ne_lat = 40.094882122321174;
var ne_long = -105.150146484375;
function loadGeoJson(data) {
console.log(data);
geojsonLayer.addData(data);
}
var geoJsonUrl = "http://gis.drcog.org/geoserver/DRCOGPUB/ows?service=WFS&version=1.0.0&request=GetFeature&typeName="+ currSelectionLayer +"&srsName=EPSG:4326&maxFeatures=10000&outputFormat=json&format_options=callback:getJson&cql_filter=BBOX(the_geom," + ne_long + "," + ne_lat + "," + sw_long + "," + sw_lat + ")";
$.ajax({
url: geoJsonUrl,
dataType: 'jsonp',
jsonpCallback: 'getJson',
contentType: 'application/json',
success: loadGeoJson
});
map.addLayer(geojsonLayer);
However, when I apply an INTERSECT filter I get this error:
Resource interpreted as Script but transferred with MIME type text/xml
Here is my code for trying to get the INTERSECT filter to work:
Un-successful request using INTERSECT filter
var geojsonLayer = new L.GeoJSON();
var currSelectionLayer = 'DRCOGPUB:rea_drcog_jurisdiction_county';
function loadGeoJson(data) {
console.log(data);
geojsonLayer.addData(data);
}
var geoJsonUrl = "http://gis.drcog.org/geoserver/DRCOGPUB/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=" + currSelectionLayer + "&srsName=EPSG:4326&maxFeatures=10000&outputFormat=json&format_options=callback:loadGeoJson&cql_filter=INTERSECT(the_geom,%20POINT%20(-105.36369323730467%2040.10013461308659)";
$.ajax({
url: geoJsonUrl,
dataType: 'jsonp',
jsonpCallback: 'getJson',
contentType: 'application/json',
success: loadGeoJson
});
map.addLayer(geojsonLayer);
I have tried many variations on the AJAX request and tweaking my Apache config but have had no luck. Any ideas would be appreciated. Please let me know if you need more info.
I enabled the mime_module (mod_mime.so) in Apache and added the content type with this config code:
AddType text/javascript .js
Final Fixed Code:
var geojsonLayer = new L.GeoJSON();
var currSelectionLayer = 'DRCOGPUB:rea_drcog_jurisdiction_county';
function loadGeoJson(data) {
console.log(data);
geojsonLayer.addData(data);
}
// using INTERSECT strategy
var geoJsonUrl = "http://gis.drcog.org/geoserver/DRCOGPUB/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=" + currSelectionLayer + "&srsName=EPSG:4326&maxFeatures=10000&outputFormat=json&format_options=callback:getJson&cql_filter=INTERSECTS(the_geom,%20POINT(-104.986145%2039.733066))";
$.ajax({
url: geoJsonUrl,
dataType: 'jsonp',
jsonpCallback: 'getJson',
contentType: 'application/json',
success: loadGeoJson
});
map.addLayer(geojsonLayer);