I'm sending a WMS GetFeatureInfo()
request, but there is something wrong because the returned info does not appropriate a clicked point.
I suspect that the error is in the BBOX parameter of the request because I'm not sure that bounds are in the correct EPSG.
How can I convert Google Maps Bounds to the EPSG:6706?
This is what I tried to do:
google.maps.event.addListener(map, "dblclick", function (e) {
if ($('#wms').is(":checked")) {
var scale = Math.pow(2, map.getZoom());
var proj = map.getProjection();
var bounds = map.getBounds();
var nw = proj.fromLatLngToPoint(
new google.maps.LatLng(
bounds.getNorthEast().lat(),
bounds.getSouthWest().lng()
));
var so = proj.fromLatLngToPoint(
new google.maps.LatLng(
bounds.getNorthEast().lng(),
bounds.getSouthWest().lat()
));
var point = proj.fromLatLngToPoint(e.latLng);
var i = Math.floor((point.x - nw.x) * scale);
var j = Math.floor((point.y - nw.y) * scale);
var w = $('#map').width();
var h = $('#map').height();
i = Math.round(i*256/w);
j = Math.round(j*256/h);
var url = "https://wms.cartografia.agenziaentrate.gov.it/inspire/wms/ows01.php?";
url += "SERVICE=WMS"; //WMS service
url += "&VERSION=1.3.0"; //WMS version
url += "&REQUEST=GetFeatureInfo"; //WMS operation
url += "&FORMAT=image/png" ; //WMS format
url += "&TRANSPARENT=TRUE";
url += "&QUERY_LAYERS=CP.CadastralParcel"; //,CP.CadastralZoning";
url += "&LAYERS=CP.CadastralParcel"; //,CP.CadastralZoning";
url += "&TILED=true";
url += "&INFO_FORMAT=text/html";
url += "&I="+i;
url += "&J="+j;
url += "&WIDTH=256"; //tile size in google
url += "&HEIGHT=256";
url += "&CRS=EPSG:6706"; //set WGS84
url += "&BBOX=" + bbox; // set bounding box
window.open(url);
}
});
This is an example of the WMS call: it works but the returned info are not correct for the point clicked.
https://wms.cartografia.agenziaentrate.gov.it/inspire/wms/ows01.php?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetFeatureInfo&FORMAT=image/png&TRANSPARENT=TRUE&QUERY_LAYERS=CP.CadastralParcel&LAYERS=CP.CadastralParcel&TILED=true&INFO_FORMAT=text/html&I=65&J=88&WIDTH=256&HEIGHT=256&CRS=EPSG:6706&BBOX=10.510482788085938,44.35429627478576,10.51116943359375,44.35478724525106