I am trying to get a pop up from my map with the getfeauture code. I tried to followed the following example. When i tried to run the code i get the following error in my console:

XMLHttpRequest cannot load http://localhost:8080/geoserver/wms?LAYERS=test%3Aput_25_vlak_1_vulling&QUE…04&FORMAT=image%2Fpng&INFO_FORMAT=text%2Fhtml&SRS=EPSG%3A28992&X=731&Y=197. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

I found some simular problems online like Access-Control-Allow-Origin in geoserver and ol3 but when i add a proxy i get the following error:

XMLHttpRequest cannot load file:///C:/Program%20Files%20(x86)/GeoServer%202.8.1/data_dir/www/proxy.cgi…g%26INFO_FORMAT%3Dtext%252Fhtml%26SRS%3DEPSG%253A28992%26X%3D751%26Y%3D189. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.

Is there somebody that can help me?

My code is as following:

OpenLayers Example OpenLayers.ProxyHost = "proxy.cgi?url="; var bounds = new OpenLayers.Bounds( 189796.953125, 427589.40625, 189836.1875, 427625.5625 );
             var options = {
                             controls: [],
                             maxExtent: bounds,
                             maxResolution: 0.02741796875,
                             projection: "EPSG:28992",
                             units: 'm'

             map = new OpenLayers.Map('map', options);

             var ccounties = new OpenLayers.Layer.WMS(
                             "test", "http://localhost:8080/geoserver/wms",
                                     srs: 'EPSG:28992',
                                     layers: 'test:put_25_vlak_1_vulling',
                             {singleTile: true, ratio: 1}
             // 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());
             map.addControl(new OpenLayers.Control.MousePosition());
    info = new OpenLayers.Control.WMSGetFeatureInfo({
        url: 'http://localhost:8080/geoserver/wms', 
        title: 'Identify features by clicking',
        queryVisible: true,
        eventListeners: {
            getfeatureinfo: function(event) {
                map.addPopup(new OpenLayers.Popup.FramedCloud(
  • 1
    is it possible you are opening the html file directly instead of through the server? check in the address bar if it starts file:// it won't work it should start http://... – Ian Turton Jan 21 '16 at 8:33
  • yes, you got it right i opened it like a file. i m downloading right now Xamp. In that way i can get a http and not file – waywer Jan 21 '16 at 9:07
  • don't do that and all will be fine – Ian Turton Jan 21 '16 at 9:11
  • how do you mean: don't do that? what should i not do? – waywer Jan 21 '16 at 9:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.