I have published the data in Geoserver (Tomcat and OS Ubuntu) and I am developing a map application in my local machine (OS windows xp) using asp.net. In my application, I can get WMS feature information in IE8 with the confirmation msg "This page is accessing information that is not under its control. This poses a security risk. Do you want to continue?" given Yes. But in Chrome, i cannt get feature info. It says
XMLHttpRequest cannot load http://xxx.xxx.x.xxx:8080/geoserver/cite/wms?LAYERS=cite%3Aplym_p1_examplec…e%2Fpng&INFO_FORMAT=application%2Fvnd.ogc.gml&SRS=EPSG%3A27700&X=596&Y=160. Origin http://localhost:3890 is not allowed by Access-Control-Allow-Origin.
I have found similar questions Using WFS protocol in OpenLayers? but its for after hosting the web application in geoserver.My case is still its in under developing in my local machine. My code is:
roadidPicker = new OpenLayers.Control.WMSGetFeatureInfo({
url: 'http://xxx.xxx.x.xxx:8080/geoserver/cite/wms',
title: 'identify features on click',
queryVisible: true
});
roadidPicker.infoFormat = 'application/vnd.ogc.gml';
roadidPicker.events.register("getfeatureinfo", this, pickRoadid);
osMap.addControl(roadidPicker);
roadidPicker.activate();
function pickRoadid(e) {
if (e.features.length > 0) {
var val = e.features[0].attributes['theme'];
alert(val);
}
}
I have configured the proxy.cgi file in Geoserver (usr/lip/cgi-bin/proxy.cgi) and added my local ip address in
allowedHosts = ['xxx.xxx.x.xxx', 'www.openlayers.org', 'openlayers.org', 'labs.metacarta.com', 'world.freemap.in', 'prototype.openmnnd.org', 'geo.openplans.org', 'sigma.openplans.org', 'demo.opengeo.org', 'www.openstreetmap.org', 'sample.azavea.com', 'v2.suite.opengeo.org', 'v-swe.uni-muenster.de:8080', 'vmap0.tiles.osgeo.org','www.openrouteservice.org']
and added the below line in my script.
OpenLayers.ProxyHost = "/cgi-bin/proxy.cgi?url=";
but it says another error in chrome console:
GET localhost:3890/usr/lib/cgi-bin/….…T%3Dapplication%252Fvnd.ogc.gml%26SRS%3DEPSG%253A27700%26X%3D682%26Y%3D284 404 (Not Found)
I dont know whether its right or wrong. Proxy.cgi should be copied in Geoserver or my machine? in which path?
Please anyone suggest me to fix this issue