[mapserver-users] Impossible to get getFeatureInfo result

Rahkonen Jukka jukka.rahkonen at mmmtike.fi
Mon Jun 17 03:10:44 PDT 2013


Hi,

Your problem is in the Leaflet code which does not take X and Y values from the mouse click and you will be better served if you ask about that from some Leaflet forum. However, there is a working GetFeatureInfo example at http://projects.bryanmcbride.com/leaflet/wms_info.html
Perhaps you will find from the code what you have done differently.

-Jukka Rahkonen-

Geo-6 wrote:

Hi I'm new to MapServer.

I'm trying to use MapServer (MS4W) as a WMS Server with Leaflet (http://leafletjs.com/)

The "GetMap" function works perfectly but I can't get a correct "GetFeatureInfo" result...

Here are some portions of my code :

Leaflet :
var map2 = L.map('map2', { /*minZoom: 8,*/ crs: L.CRS.EPSG3857 }).setView([50.495958, 4.42749], 8);
map2.on("click", function(e) {
    var latlngStr = '(' + e.latlng.lat.toFixed(3) + ', ' + e.latlng.lng.toFixed(3) + ')';
    var SRS = map2.options.crs.code;
    var BBOX = map2.getBounds().toBBoxString();
    var WIDTH = map2.getSize().x;
    var HEIGHT = map2.getSize().y;
    var X = map2.layerPointToContainerPoint(e.layerPoint).x;
    var Y = map2.layerPointToContainerPoint(e.layerPoint).y;
    var URL = '&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetFeatureInfo&LAYERS=TEST_KM_L7P&QUERY_LAYERS=TEST_KM_L7P&STYLES=&BBOX='+BBOX+'&HEIGHT='+HEIGHT+'&WIDTH='+WIDTH+'&FORMAT=image%2Fpng&INFO_FORMAT=text%2Fhtml&SRS='+SRS+'&X='+X+'&Y='+Y;
    $.ajax({
        url: "http://www.geocode.be/cgi-bin/mapserv.exe?map=D:/Data/Vector/test_km_L7p_wms.map",
        dataType: "html",
        type: "GET",
        //async: false,
        success: function(data) {
            //console.log(data);
            $("#url").text("http://www.geocode.be/cgi-bin/mapserv.exe?map=D:/Data/Vector/test_km_L7p_wms.map" + URL)
            $("#console").html(data);
        }
    });
});

MapServer MAP File :
MAP
    NAME "Test2"
    STATUS ON
    SIZE 600 400
    #SYMBOLSET "../etc/symbols.txt"
    EXTENT 0 0 300000 300000
    #UNITS DD
    #SHAPEPATH "../data"
    IMAGECOLOR 255 255 255
    #FONTSET "../etc/fonts.txt"
    CONFIG "PROJ_LIB" "./proj/nad/"

    CONFIG "MS_ERRORFILE" "D:/Data/Vector/ms_error.txt"
    CONFIG "CPL_DEBUG" "OFF"
    CONFIG "PROJ_DEBUG" "ON"
    DEBUG 3

    #
    # Start of web interface definition
    #
    WEB
        IMAGEPATH "D:/VH_DEFAULT/Temp/"
        IMAGEURL "/Temp/"
        METADATA
            "wms_abstract" "Demo for map context document. Blah blah..."
            "wms_title" "Map Context demo"   #### REQUIRED
            "wms_enable_request" "*"
            "wms_srs" "EPSG:31370 EPSG:4326 EPSG:3857"
            "wms_feature_info_mime_type" "text/plain text/html"
        END
        TEMPLATE "blank.html"
    END

    PROJECTION
        "init=epsg:31370"
    END

    #
    # Start of layer definitions
    #
    LAYER
        NAME TEST_KM_L7P
        TYPE LINE
        STATUS ON
        CONNECTIONTYPE OGR
        CONNECTION "./test_km_L7p.TAB"
        STYLEITEM "AUTO"
        DUMP TRUE
        TEMPLATE "blank.html"
        CLASS
            NAME "TEST_KM_L7P"
        END
        METADATA
            "wms_title" "TEST_KM_L7P"  #### REQUIRED
            "wms_enable_request" "*"
            "gml_include_items" "all"
            "wms_include_items" "all"
        END
    END # Layer
END # Map

My TEMPLATE file is correctly loaded but every time, no matter where I click on the map, the [mapx], [mapy] = -1.000000, -1.000000 and [maplon], [maplat] = 2.305489, 49.293903

I really does not see where the error is.

Thanks for your help.
Have a good day.

PS: Sorry for my bad english

Jonathan Beliën
Geo-6

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20130617/82ba2d32/attachment-0001.html>


More information about the mapserver-users mailing list