[OpenLayers-Users] GetFeatureInfo on ASP.NET platform with MapServer finally working

sunny74 sb.ray at hotmail.com
Mon Apr 12 03:01:53 EDT 2010


Dear  Friends,

This is to inform you that I had struggled  a lot to GetFeatureInfo working
on the ASP.NET platform(on windowsXP, IIS 5.1 and Visual Studio 2008).
I would like to put on record the main points of the solution so that
another guy need not have to break his head in order to get it working.
I had made several posts in order to understand the different concepts
involved in it.The posts are:


http://n2.nabble.com/getting-Feature-Info-data-directly-from-shp-files-td4767879.html#a4767879 
http://n2.nabble.com/Get-Feature-Info-in-pop-up-working-example-td4773944.html#a4773944  
http://n2.nabble.com/WFS-map-from-shapefiles-td4795937.html#a4795937 
http://n2.nabble.com/Proxy-problem-in-GetFeatureInfo-no-solution-td4802810.html#a4802810 
http://n2.nabble.com/Opemlayers-loadURL-does-not-work-in-GetFeatureInfo-td4822969.html#a4822969
http://n2.nabble.com/getting-Feature-Info-data-directly-from-shp-files-td4767879.html#a4767879 

http://n2.nabble.com/getting-Feature-Info-data-directly-from-shp-files-td4767879.html#a4767879 
http://n2.nabble.com/Get-Feature-Info-in-pop-up-working-example-td4773944.html#a4773944  
http://n2.nabble.com/WFS-map-from-shapefiles-td4795937.html#a4795937 
http://n2.nabble.com/Proxy-problem-in-GetFeatureInfo-no-solution-td4802810.html#a4802810 
http://n2.nabble.com/Opemlayers-loadURL-does-not-work-in-GetFeatureInfo-td4822969.html#a4822969
http://n2.nabble.com/Get-Feature-Info-in-pop-up-working-example-td4773944.html#a4773944


http://n2.nabble.com/getting-Feature-Info-data-directly-from-shp-files-td4767879.html#a4767879 
http://n2.nabble.com/Get-Feature-Info-in-pop-up-working-example-td4773944.html#a4773944  
http://n2.nabble.com/WFS-map-from-shapefiles-td4795937.html#a4795937 
http://n2.nabble.com/Proxy-problem-in-GetFeatureInfo-no-solution-td4802810.html#a4802810 
http://n2.nabble.com/Opemlayers-loadURL-does-not-work-in-GetFeatureInfo-td4822969.html#a4822969
http://n2.nabble.com/WFS-map-from-shapefiles-td4795937.html#a4795937 

http://n2.nabble.com/getting-Feature-Info-data-directly-from-shp-files-td4767879.html#a4767879 
http://n2.nabble.com/Get-Feature-Info-in-pop-up-working-example-td4773944.html#a4773944  
http://n2.nabble.com/WFS-map-from-shapefiles-td4795937.html#a4795937 
http://n2.nabble.com/Proxy-problem-in-GetFeatureInfo-no-solution-td4802810.html#a4802810 
http://n2.nabble.com/Opemlayers-loadURL-does-not-work-in-GetFeatureInfo-td4822969.html#a4822969
http://n2.nabble.com/Proxy-problem-in-GetFeatureInfo-no-solution-td4802810.html#a4802810 

http://n2.nabble.com/getting-Feature-Info-data-directly-from-shp-files-td4767879.html#a4767879 
http://n2.nabble.com/Get-Feature-Info-in-pop-up-working-example-td4773944.html#a4773944  
http://n2.nabble.com/WFS-map-from-shapefiles-td4795937.html#a4795937 
http://n2.nabble.com/Proxy-problem-in-GetFeatureInfo-no-solution-td4802810.html#a4802810 
http://n2.nabble.com/Opemlayers-loadURL-does-not-work-in-GetFeatureInfo-td4822969.html#a4822969
http://n2.nabble.com/Opemlayers-loadURL-does-not-work-in-GetFeatureInfo-td4822969.html#a4822969 

Initially there was confusion as to whether GetFeatureInfo can work on a WMS
layer or a WFS layer is required from MapServer.
Finally it turned out that it works on WMS layer i.e WFS is not required.
The GFI code that finally worked is as given below although there are other
similar looking code.

OpenLayers.ProxyHost = "/cgi-bin/proxy.cgi?url=";
        //alert('here');
        var lon = 74.25;
        var lat = 20.35;
        var zoom = 6;
        map = new OpenLayers.Map('<%=map.ClientID%>');
        //            layer = new OpenLayers.Layer.WMS("OpenLayers WMS",
        //                "http://localhost:9000/cgi-bin/mapserv.exe?", {
map: '../htdocs/Shape/newwr1rec.map', layers: 'STATE', format: 'png' });
        //            layer1 = new OpenLayers.Layer.WMS("Rstations",
        //                "http://localhost:9000/cgi-bin/mapserv.exe?", {
map: '../htdocs/Shape/newwr1rec.map', transparent: true, layers:
'RailwayStations', format: 'png' });
        //alert(map);
        layer = new OpenLayers.Layer.WMS("OpenLayers WMS",
"/mapserver/mapserv.exe?map=c:/ms4w/apache/htdocs/Shape/newwr1rec.map", {
'layers': 'STATE', transparent: false, format: "image/png" });
        layer1 = new OpenLayers.Layer.WMS("OpenLayers WMS",
"/mapserver/mapserv.exe?map=c:/ms4w/apache/htdocs/Shape/newwr1rec.map", {
'layers': 'RailwayStations', transparent: true, format: "image/png" });
        //alert(layer);
        map.addLayers([layer, layer1]);

        //layer = new OpenLayers.Layer.WFS("OpenLayers WFS",
"http://127.0.0.1:9000/cgi-bin/mapserv.exe?map=d:/ms4w/apache/htdocs/Shape/newwr1.map",
{ typename: 'STATE', maxfeatures: 6 }, { featureClass:
OpenLayers.Feature.WFS });

        ///map.addLayer(layer);


        map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
        map.addControl(new OpenLayers.Control.LayerSwitcher());
        
map.events.register('click', map, function(e) {
            //alert('clicked');
            OpenLayers.Util.getElement('nodeList').innerHTML = "Loading...
please wait...";
            var url = layer1.getFullRequestString({
                REQUEST: "GetFeatureInfo",
                EXCEPTIONS: "application/vnd.ogc.se_xml",
                BBOX: layer1.map.getExtent().toBBOX(),
                X: e.xy.x,
                Y: e.xy.y,
                INFO_FORMAT: 'text/plain',
                QUERY_LAYERS: layer1.params.LAYERS,
                
                FEATURE_COUNT: 1,
                WIDTH: map.size.w,
                HEIGHT: map.size.h
            });
            //  var msg = document.getElementById('urlmsg');
            //  msg.value = url;
            alert(url, "getfeatureinfo",
"location=0,status=0,scrollbars=1,width=800,height=400");
            ///window.open(url, '', this, setHTML, setHTML);
            OpenLayers.loadURL(url, '', this, setHTML);
            OpenLayers.Event.stop(e);
        });

Initially I had a few errors in my code but even after correcting them I did
not either get an output or got proxy related errors.
Then one of the forum members Arnd Wippermann pointed out that since I was
using two web servers i.e Apache and IIS, two domains were created and as a
result of which GFI request could not go through i.e blocked by proxy.
While IIS was loading the aspx page,Apache was being used to call mapserver
using OL within that aspx page.
Then I realized that I need to have one server i.e IIS do both the things
i.e load the aspx page as well as call mapserver within the aspx page.
So I configured IIS 5.1 to call mapserver(cgi executable) and after that the
above code started working.

How to configure IIS 5.1 to directly call Mapserver?

Please refer to the attached document. If you need help regarding
configuring IIS 6.0/7.0 let me know.

The solution I have stated above could not be found anywhere in the
Internet, could only find people with problems with respect
to GFI and no solution whatsoever.

I hope this solution will go a long way in solving the issues surrounding
GFI,especially  those using the ASP.NET platform.

Thanks to all members who participated in my posts and tried to help me.
Special Thanks to Arnd Wippermann for correcting my errors in code and also
for explaining the
concept of two domains being created due to the use of two web servers and
how to avoid the proxy by having everything in one domain.He cleared most of
my doubts as a result of which there is a working solution now.

http://n2.nabble.com/file/n4888720/Configuring_IIS_5.1_to_run_Mapserver_directly_on_it%2528without_using_Apache%2529.doc
Configuring_IIS_5.1_to_run_Mapserver_directly_on_it%28without_using_Apache%29.doc 
-- 
View this message in context: http://n2.nabble.com/GetFeatureInfo-on-ASP-NET-platform-with-MapServer-finally-working-tp4888720p4888720.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.



More information about the Users mailing list