OS OpenSpace [logo]

OS OpenSpace Forum » OS OpenSpace » API Development Help

Thread: GetFeatureInfo Help

Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 4 - Pages: 1 - Last Post: 03-Jan-2012 14:15 by: Guest
Guest
GetFeatureInfo Help
Posted: 19-Dec-2011 16:56
  Click to reply to this thread Reply

Hi there,

We have just started assessing the capabilities of OpenSpace and Geoserver, and am having some problems getting the GetFeatureInfo function to work. I seem to be running into the Origin http://localhost is not allowed by Access-Control-Allow-Origin problem that I have spotted on the web. Yes, currently I am running the site from a localhost but this is supposed to be supported for development, and unfortunately the Openlayers provided proxy workaround doesn't seem to work.

Can anyone advise on whether the problem I am having is this issue and whether there are any other work-arounds except for using a proxy server?

shawkes

Posts: 61
Registered: 22/01/10
Re: GetFeatureInfo Help
Posted: 20-Dec-2011 08:59   in response to: Guest
  Click to reply to this thread Reply

If your map is being served from localhost and your target for GetGeatureInfo is localhost then you should not need a proxy. What makes you think you are running into the Access-Control-Allow-Origin problem?

Guest
Re: GetFeatureInfo Help
Posted: 20-Dec-2011 09:18   in response to: shawkes
  Click to reply to this thread Reply

Sorry was in a bit of rush last night and didn't post as many details as I should. The reason I think it is this problem is that I get this when I try GetFeatureInfo:

XMLHttpRequest cannot load http://localhost:8080/geoserver/Crossrail_Test/wms?service=WMS&version=1.1.0&request=GetFeatureInfo&layers=Crossrail_Test%3ATBM_PATH_OS&query_layers=Crossrail_Test%3ATBM_PATH_OS&styles=&bbox=532120%2C178323%2C540120%2C184323&srs=EPSG%3A27700&feature_count=10&x=429&y=325&height=600&width=800&info_format=text%2Fhtml. Origin http://localhost is not allowed by Access-Control-Allow-Origin.

I'm a little confused admittedly as the layer I am trying to query is on the localhost, but because I am using the Openspace API rather than Openlayers API within Geoserver, the request is being sent through this and not the localhost?

shawkes

Posts: 61
Registered: 22/01/10
Re: GetFeatureInfo Help
Posted: 21-Dec-2011 11:06   in response to: Guest
  Click to reply to this thread Reply

Ah, I see. It is not a difference between the Openspace API and Openlayers API but your GeoServer is running on port 8080 and your map on port 80. So even though both are on localhost, too JavaScript they are totally different websites and so do not have the same origin.
So you either need too get your map on to the GeoServer site (localhost:8080) or you will need to set up a proxy on your localhost:80 that forwards the request onto localhost:8080

Has that made things any clearer?

Guest
Re: GetFeatureInfo Help
Posted: 03-Jan-2012 14:15   in response to: Guest
  Click to reply to this thread Reply

Hi,

Just to let you know I eventually found a way around this, using the link below:

http://khayer.wordpress.com/2010/07/04/solution-of-cross-domain-ajax-call-problem/

I'll admit there are some caveats on it's use but it was very helpful and fixed the problem without having to go too far down the proxy route.

Legend
Expert: 51 - 1000 pts
Advanced: 31 - 50 pts
Intermediate: 16 - 30 pts
Novice: 5 - 15 pts
Newbie: 0 - 4 pts
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums