[mapserver-users] Query feature using openlayers and mapserver

Aypes apestgas at yahoo.com.hk
Wed Oct 28 23:13:54 PDT 2009


Dear all, 

I might open a topic in a wrong forum, because I do not know whether I
should ask this question in Mapserver or OpenLayers forum. If I did, I feel
sorry about that. 

I want to query the layer with using openlayers. However, I do not know how
to 'call' the templates from mapfile to the html file.I have found topics
about query using mapserver and openlayers, but I have still no idea how to
code in html file. The query function is fine when using mapserver alone. 

In the mapfile, I have put metadata into web like this: 
WEB 
        HEADER "/ms4w/Apache/htdocs/web_header.html" 
        FOOTER "/ms4w/Apache/htdocs/web_footer.html" 
        EMPTY  "empty.html" 
        Metadata 
        "wms_title" "WMS" 
        "wms_onlineresource"
"http://localhost/cgi-bin/mapserv.exe?map=c:/ms4w/Apache/htdocs/test.map&" 
        "wms_srs"       "EPSG:4269" 
        "wms_feature_info_mime_type" "text/html" 
        END 
        template "/ms4w/Apache/htdocs/web.html" 
        imagepath "/ms4w/Apache/htdocs/tmp/" 
        imageurl "/tmp/" 
END 
PROJECTION 
        "init=epsg:4269" 
END 

And in the layer, data from postgresql postgis (with attribute ID) was used
with metadata: 
Name "Abc" 
metadata 
                "wms_title" "Abc" 
                "wms_srs" "EPSG:4269" 
End 
..... 

I also have put header footer in layer and template in the class 
Class 
        Name "abc" 
        Template "/ms4w/Apache/htdocs/query.html" 
             ...... 
END 

The code in html file: 
var layer = new OpenLayers.Layer.MapServer( "ABC WMS",   
       
"http://localhost/cgi-bin/mapserv.exe?map=c:/ms4w/Apache/htdocs/test.map&", 
        {layers: 'Abc'} ); 
I tried {layers: 'Abc', mode: 'query', params ='ID'}  but it did not work. 

I found an example of query: http://www.co.sweet.wy.us/mapserver/map.html
I want to query the layer by a click instead of dragging and a new window
come out to display information. 
How can I make this in html file? 

Furthermore, I find many examples using new OpenLayers.Layer.WMS. But when I
use it, it displays nothing. I can only use new OpenLayers.Layer.MapServer
to display map. What is the problem? 


Thanks, 
Aypes 
-- 
View this message in context: http://n2.nabble.com/Query-feature-using-openlayers-and-mapserver-tp3910093p3910093.html
Sent from the Mapserver - User mailing list archive at Nabble.com.



More information about the MapServer-users mailing list