Hi,
This list is intended for when you *develop* OpenLayers, ie: if you're
modifying OpenLayers classes, creating subclasses, or otherwise getting
into the guts of OpenLayers.
Your questions are questions about how to *use* OpenLayers and
MapServer. Please use the following lists for them:
OpenLayers:
http://lists.osgeo.org/mailman/listinfo/openlayers-users
MapServer:
http://lists.osgeo.org/mailman/listinfo/mapserver-users
Regards, Roald
On 28/09/11 21:05, jcbpro81 wrote:
Hello everyone,
I'm new with OpenLayers and MapServer.
I'm looking for a way to get informations on a feature clicked on a map,
like on the following link :
http://openlayers.org/dev/examples/getfeatureinfo-control.html
Here is my environment:
OpenLayers load only one layer of type "OpenLayers.Layer.MapServer".
The mapfile contains 4 postgis layers, and I want to be able to retrieve
informations from one of them.
Here is the JavaScript I have for now according to the GetFeatureInfo, code
found by looking on Google :
-------------------------------------------------------------------------------------------
layer = new OpenLayers.Layer.MapServer("myMap", "url", {map:
'file.map'});
map.addLayers([layer]);
map.events.register('click', map, function(evt) {
document.getElementById("infoResult").innerHTML = "Recherche en
cours..."
var url = layer.getFullRequestString({
REQUEST: "GetFeatureInfo",
EXCEPTIONS: "application/vnd.ogc.se_xml",
STYLES: "",
BBOX: map.getExtent().toBBOX(),
X: evt.xy.x,
Y: evt.xy.y,
QUERY_LAYERS: "myLayer",
FEATURE_COUNT: 1,
WIDTH: map.size.w,
HEIGHT: map.size.h,
INFO_FORMAT: 'text/html'
});
//alert(url);
OpenLayers.loadURL(url, '', this, setInfoResult);
Event.stop(evt);
});
// ....
function setInfoResult(response) {
//alert(response);
document.getElementById("infoResult").innerHTML =
response.responseText;
}
-------------------------------------------------------------------------------------------
When I click anywhere on the map, the "infoResult" shows "?PNG " (the
display is a square next to "PNG" characters).
So I'm questionning myself on what I'm doing wrong.
About the QUERY_LAYERS parameter, with value "myLayer", do I have to put the
name of the layer loaded with OpenLayers ("myMap") or the name of a layer
inside of my mapfile ("myLayer") ?
Is this code can work with postgis layers ?
Do I have to work in another way ?
I find that OpenLayers online help
(http://dev.openlayers.org/releases/OpenLayers-2.9/doc/apidocs/index/General.html)
isn't really "user friendly" and hard to understand.
I spent lot of days to be able to simply display a map.
Any help will be much apprecied.
Thanks in advance.
Regards,
--
View this message in context:
http://osgeo-org.1803224.n2.nabble.com/use-of-GetFeatureInfo-with-MapServer-file-tp6839763p6839763.html
Sent from the OpenLayers Dev mailing list archive at Nabble.com.
_______________________________________________
Dev mailing list
d...@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-dev
_______________________________________________
Dev mailing list
d...@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-dev