0

I've searched for answer for the last couple of days with no success.

When I click on an object on the screen I get this reply from the server:

http://localhost/cgi-bin/mapserv.exe?LAYERS=testpoint&QUERY_LAYERS=testpoint&STYLES=&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetFeatureInfo&BBOX=517948%2C157505%2C535448%2C170005&FEATURE_COUNT=1&HEIGHT=500&WIDTH=700&FORMAT=image%2Fpng&INFO_FORMAT=text%2Fhtml&SRS=EPSG%3A27700&X=357&Y=241&MAP=%2FWorkTemp%2Ftest.map

Following this link returns the value for the object I just picked. I get no errors in the MapServer or OpenLayers log file.

OpenLayers code:

layer = new OpenLayers.Layer.WMS( "WMS data","http://localhost/cgi-bin/mapserv.exe?", {layers: 'testpoint' , map: '/WorkTemp/test.map', transparent: true},{isBaseLayer: false, opacity: 1, singleTile: true, visibility: true});

osMap.addLayer(layer);

info = new OpenLayers.Control.WMSGetFeatureInfo({
       url: 'http://localhost/cgi-bin/mapserv.exe?',
       title: 'Identify features by clicking',
       queryVisible: true,
       maxFeatures: 1,
       vendorParams: {
            map: '/WorkTemp/test.map'
       } ,
       info_format: 'text/html',
       layers: [layer],
       eventListeners: {
       getfeatureinfo: function(event) {
             if(event.features.length > 0) {
                     osMap.addPopup(new OpenLayers.Popup.FramedCloud(
                     "chicken", 
                     osMap.getLonLatFromPixel(event.xy),
                     null,
                     event.text,
                     null,
                     true
                     ));
             }
       }
       }
});

osMap.addControl(info);
info.activate();

test.map layer

LAYER
  NAME "testpoint"
  TYPE POINT
  STATUS ON
  CONNECTIONTYPE OGR
  CONNECTION "MYSQL:test,host=localhost,user=root,password=xxxxxx,port=3306"
  DATA "SELECT SHAPE,test from testpoint"
  DUMP TRUE

    TEMPLATE "c:\WorkTemp\test_template.html"


  LABELITEM "test"
   PROJECTION
        "init=epsg:27700"
    END
  CLASS
    NAME "test"
    STYLE
      SYMBOL  'circle'
      SIZE 10
      COLOR 255 215 0
    END
    LABEL
     COLOR  0 0 0
     FONT arial
     TYPE truetype
     SIZE 8
     POSITION AUTO
     PARTIALS FALSE
     OUTLINECOLOR 255 255 255
    END
  END
END # layer

This appears to be the same problem that I'm having:- Use OpenLayers WMSGetFeatureInfo on Mapserver Layer?, but I have already set my WMS layer to be OpenLayers.Layer.WMS

I downloaded and installed OSGEO4W as my starting point. I'm calling http://openspace.ordnancesurvey.co.uk/osmapapi/openspace.js for my OpenLayers commands.

Any suggestions would be gratefully appreciated.

  • 1
    where are you loading your html page from? do you have a proxy? – Ian Turton Sep 10 '13 at 12:24
  • Html is loading from c:\worktemp. I'm not using a proxy. – Char Sep 10 '13 at 12:51
  • you'll either need to load from localhost or use a proxy (and even then I doubt it will work from c:) – Ian Turton Sep 10 '13 at 13:26
  • cheers iant. I've moved the files to localhost. same problem. :( – Char Sep 10 '13 at 14:45
  • what does firebug say – Ian Turton Sep 10 '13 at 14:49
0

Ok. I've come back to this project and I've managed to solve my problem.

Its all down to the response from the WMS request (text/html). This Value was never created "event.features.length". I changed it to checking that event.text had a string length greater than 0. I'm now getting popups appearing.

Feels obvious now :(

  • You should mark this as the accepted answer so that future readers will quickly know how to solve the problem. You may have to wait a day or two before you can accept it. – user3461 Oct 31 '13 at 13:51

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.