[OpenLayers-Users] GetFeatureInfo problem
Nguyen Le Minh
nlminh79 at yahoo.com
Wed Jun 12 05:18:51 PDT 2013
Hi all,
I install Geoserver 2.3.2 on Window OS. I write one
HTML script which use openlayers to view my own layer also want to get
information of my layer by GetfeatureInfo. I put this HTML file into HOME_GEOSERVER/data_dir/www. But currently I
just viewed my layer. For getting information, it still not work. I
though that it due to proxy problems. Could you help me to solve this problem? My main code is bellow:
<script src="http://localhost:8080/geoserver/openlayers/OpenLayers.js" type="text/javascript"> </script> <script defer="defer" type="text/javascript">
var map;
var untiled;
var tiled;
var pureCoverage = false;
// pink tile avoidance
OpenLayers.IMAGE_RELOAD_ATTEMPTS = 5;
// make OL compute scale according to WMS spec
OpenLayers.DOTS_PER_INCH = 25.4 / 0.28;
function init(){
// if this is just a coverage or a group of them, disable a few items,
// and default to jpeg format
format = 'image/png';
if(pureCoverage) {
document.getElementById('filterType').disabled = true;
document.getElementById('filter').disabled = true;
document.getElementById('antialiasSelector').disabled = true;
document.getElementById('updateFilterButton').disabled = true;
document.getElementById('resetFilterButton').disabled = true;
document.getElementById('jpeg').selected = true;
format = "image/jpeg";
}
var bounds = new OpenLayers.Bounds(
103.0183000000001, 8.695100000000009,
109.12200000000011, 22.827400000000026
);
var options = {
controls: [],
maxExtent: bounds,
maxResolution: 0.0552042968750001,
projection: "EPSG:4326",
units: 'degrees'
};
map = new OpenLayers.Map('map', options);
// setup tiled layer
tiled = new OpenLayers.Layer.WMS(
"Minh_test:30_station_06_2013 - Tiled", "http://localhost:8080/geoserver/Minh_test/wms",
{
LAYERS: 'Minh_test:30_station_06_2013',
STYLES: '',
format: format,
tiled: true,
tilesOrigin : map.maxExtent.left + ',' + map.maxExtent.bottom
},
{
buffer: 0,
displayOutsideMaxExtent: true,
isBaseLayer: true,
yx : {'EPSG:4326' : true}
}
);
// setup single tiled layer
untiled = new OpenLayers.Layer.WMS(
"Minh_test:30_station_06_2013 - Untiled", "http://localhost:8080/geoserver/Minh_test/wms",
{
LAYERS: 'Minh_test:30_station_06_2013',
STYLES: '',
format: format
},
{
singleTile: true,
ratio: 1,
isBaseLayer: true,
yx : {'EPSG:4326' : true}
}
);
map.addLayers([untiled, tiled]);
// build up all controls
map.addControl(new OpenLayers.Control.PanZoomBar({
position: new OpenLayers.Pixel(2, 15)
}));
map.addControl(new OpenLayers.Control.Navigation());
map.addControl(new OpenLayers.Control.Scale($('scale')));
map.addControl(new OpenLayers.Control.MousePosition({element: $('location')}));
map.zoomToExtent(bounds);
// wire up the option button
var options = document.getElementById("options");
options.onclick = toggleControlPanel;
// support GetFeatureInfo
map.events.register('click', map, function (e) {
document.getElementById('nodelist').innerHTML = "Loading... please wait...";
var params = {
//var url = prox.getFullRequestString({
REQUEST: "GetFeatureInfo",
EXCEPTIONS: "application/vnd.ogc.se_xml",
BBOX: map.getExtent().toBBOX(),
SERVICE: "WMS",
INFO_FORMAT: 'text/html',
QUERY_LAYERS: map.layers[0].params.LAYERS,
FEATURE_COUNT: 50,
Layers: 'Minh_test:30_station_06_2013',
WIDTH: map.size.w,
HEIGHT: map.size.h,
format: format,
styles: map.layers[0].params.STYLES,
srs: map.layers[0].params.SRS};
// handle the wms 1.3 vs wms 1.1 madness
if(map.layers[0].params.VERSION == "1.3.0") {
params.version = "1.3.0";
params.j = parseInt(e.xy.x);
params.i = parseInt(e.xy.y);
} else {
params.version = "1.1.1";
params.x = parseInt(e.xy.x);
params.y = parseInt(e.xy.y);
}
// merge filters
if(map.layers[0].params.CQL_FILTER != null) {
params.cql_filter = map.layers[0].params.CQL_FILTER;
}
if(map.layers[0].params.FILTER != null) {
params.filter = map.layers[0].params.FILTER;
}
if(map.layers[0].params.FEATUREID) {
params.featureid = map.layers[0].params.FEATUREID;
}
//var url = "http://localhost:8080/geoserver/Minh_test/wms";
OpenLayers.loadURL("http://localhost:8080/geoserver/Minh_test/wms", params, this, setHTML, setHTML);
OpenLayers.Event.stop(e);
});
}
// sets the HTML provided into the nodelist element
function setHTML(response){
document.getElementById('nodelist').innerHTML = response.responseText;
//response.responseText; evt.text;
};
Thank you all.
Nguyen Le Minh Ph.D.
Department of Seismological Survey, Institute of Geophysics
Vietnam Academy of Science and Technology
A8, 18 Hoang Quoc Viet, CauGiay, HaNoi, VietNam
Tel: (84) 437562799
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20130612/d2d07f61/attachment-0001.html>
More information about the Users
mailing list