Discussion:
Openlayers 3 getGetFeatureInfoUrl geoserver problem
(too old to reply)
sm_aleksey
2016-10-04 07:55:51 UTC
Permalink
I try to use Openlayers 3 DragBox for BoxSelection ang get selected feature
info from wms source. Layer projection EPSG:4326
My code:

var host = 'http://x.x.x.x/geoserver/wms'
var view = new ol.View({
center: [12018110.072132599, 6954779.226347315],
projection: 'EPSG:3857',
zoom: 6
});

var wmsStation = new ol.source.TileWMS({
url: host,
params: {
'LAYERS': 'baikalgeol:station_psg',
'TILED': true,
'VERSION': '1.1.1'
},
serverType: 'geoserver',
crossOrigin: 'anonymous'
});

var layerStation = new ol.layer.Tile({
title: 'Station',
source: wmsStation,
});

var map = new ol.Map({
pixelRatio: 1,
controls: ol.control.defaults().extend([
new ol.control.ScaleLine({
units: 'metric'
})
]),
renderer: 'canvas',
target: 'map',
layers: [
new ol.layer.Group({
layerStation,
...
})
],
view: view
});

var dragBox = new ol.interaction.DragBox({
condition: ol.events.condition.platformModifierKeyOnly
});

map.addInteraction(dragBox);

dragBox.on('boxend', function(evt) {
var info = []
var extent = dragBox.getGeometry().getExtent();
console.log(extent)
// extent = ol.proj.transformExtent(extent, 'EPSG:3857',
'EPSG:4326')
// extent = [extent[1], extent[0], extent[3], extent[2]]
console.log(extent)
var source = wmsStation;
var viewResolution = map.getView().getResolution();
var queryLayers = source.getParams().LAYERS;
var url = source.getGetFeatureInfoUrl(extent, viewResolution,
'EPSG:3857', {
'INFO_FORMAT': 'text/html',
'QUERY_LAYERS': queryLayers,
'VERSION': '1.1.1'
});


if (url) {
// url = url.replace('&CRS=', '&SRS=')
console.log(url)
document.getElementById('info').innerHTML =
'<iframe id="frame" seamless src="' + url + '"></iframe>';
}
});

But geoserver not return feature, only empty html.

URL:
http://x.x.x.x/geoserver/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetFeatureInfo&FORMAT=image%2Fpng&TRANSPARENT=true&QUERY_LAYERS=baikalgeol%3Astation_psg&LAYERS=baikalgeol%3Astation_psg&TILED=true&INFO_FORMAT=text%2Fhtml&X=0&Y=255&WIDTH=256&HEIGHT=256&SRS=EPSG%3A3857&STYLES=&BBOX=0%2C0%2C626172.1357121639%2C626172.1357121639

I think the problem in the extent. I tried transform extent coordinates for
layer projection and changed getGetFeatureInfoUrl projection:

extent = ol.proj.transformExtent(extent, 'EPSG:3857', 'EPSG:4326')
...
var url = source.getGetFeatureInfoUrl(extent, viewResolution, 'EPSG:4326'...

But geoserver return: 655, -176 not in dimensions of image: 256, 256



--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Openlayers-3-getGetFeatureInfoUrl-geoserver-problem-tp5289158.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
Loading...