Hey Emmanuel,
as long as the site you´re running is on the same server as the Geoserver
there should be no problems with the GetFeatureRequests due to
Same-Origin-Policy.
Concerning the code I could imagine that there´s a problem with the
QUERY_LAYERS-param. I guess you copied that code-snippet directly from a
Geoserver-Layer-Preview but left that param unaltered. You could either
replace that with the same content as the layers-param
('thesis:SLChiefdoms_adm3') or fill in the right pointer to the
array-position, where your layer is. But I think the first is the easier
way.
Concerning the output of the response: You can place it in every div you
want to. But you could also create a popup at the position you clicked at.
I´ve done that once via placing this code before the
OpenLayers.loadURL(
-row:
popupCoordPx = new OpenLayers.Pixel(e.xy.x, e.xy.y);
popupCoord = map.getLonLatFromPixel(popupCoordPx);
It safes the pixel-coordinates where you have clicked on the map. You should
have define the variables popupCoordPx and PopupCoord as global variables.
Otherwise other functions won´t be able to access them.
In the setHTML-function you refer to that when you create the popup for
example like this:
if(popup != null){map.removePopup(popup);}
popup = new OpenLayers.Popup.FramedCloud("chicken", popupCoord,
new OpenLayers.Size(200,200),
response.responseText,
null,
true,
null);
popup.closeOnMove = true;
popup.panMapIfOutOfView=true;
map.addPopup(popup);
Best regards,
Max Stephan
Von: Emmanuel L [mailto:[email protected]]
Gesendet: Sonntag, 20. Februar 2011 19:03
An: [email protected]
Betreff: [Geoserver-users] GetFeatureInfo Support
Dear All,
I run OpenLayers on Geoserver and I have some features which i would like
the user to click on and get information, say GetFeatureInfo. I have tried a
few help but they don't seem to help me (see the code below) - I only see a
blank space, no result. I am new to these things, don't know what is wrong
but I need to get something done here. Can somebody please tell me what is
wrong? I work on my university server but Geoserver is installed on my local
machine, not over the server. Does that have anything to do with my result.
Somebody please help. The result can be wrapped in a popup textbox or
somewhere on the map window. A step-by-step guide will be very much
appreciated because i don't even know if i need to add something before this
code or after it. Thanks a million!!
//Code used to support GetFeatureInfo request
map.events.register('click', map, function (e) {
document.getElementById('nodelist').innerHTML =
"Loading... please wait...";
var params = {
REQUEST: "GetFeatureInfo",
EXCEPTIONS: "application/vnd.ogc.se_xml",
BBOX: map.getExtent().toBBOX(),
X: e.xy.x,
Y: e.xy.y,
INFO_FORMAT: 'text/html',
QUERY_LAYERS: map.layers[0].params.LAYERS,
FEATURE_COUNT: 50,
Layers: 'thesis:SLChiefdoms_adm3',
Styles: '',
Srs: 'EPSG:32628',
WIDTH: map.size.w,
HEIGHT: map.size.h,
format: format};
OpenLayers.loadURL("http://localhost:8090/geoserver/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;
};
------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users