AW: [mapserver-users] Query feature using openlayers and mapserver

Aypes apestgas at yahoo.com.hk
Tue Nov 3 23:06:55 EST 2009




Arnd Wippermann wrote:
> 
> Hi,
> 
> Look for the visibility of your "querylayer" and decide what to do
> 
> map.events.register('click', map, function (e) 
> {
>     var flag=map.getLayersBy("name", "querylayer")[0].visibility;
> 
>     if(flag)
>     {
>         var url = "http://localhost/cgi-bin/mapserv.exe"
>           + "?map=map/file/directory.map" 
>           + "&REQUEST=GetFeatureInfo"
>           + "&VERSION=1.1.1"
>           + "&EXCEPTIONS=application/vnd.ogc.se_xml"
>           + "&BBOX=" 
>           + map.getExtent().toBBOX()
>           + "&X=" + e.xy.x
>           + "&Y=" + e.xy.y
>           + "&INFO_FORMAT=text/html"
>           + "&QUERY_LAYERS=querylayer"
>           + "&LAYERS=querylayer"
>           + "&FEATURE_COUNT=1"
>           + "&SRS=EPSG:4269"
>           + "&STYLES="
>           + "&WIDTH=" + map.size.w
>           + "&HEIGHT=" + map.size.h;
>         window.open(url, "getfeatureinfo",
> "location=0,status=0,scrollbars=1,width=600,height=400");
>     }
> });     
> 
> Regards,
> Arnd
> 
> -----Ursprüngliche Nachricht-----
> Von: mapserver-users-bounces at lists.osgeo.org
> [mailto:mapserver-users-bounces at lists.osgeo.org] Im Auftrag von Aypes
> Gesendet: Dienstag, 3. November 2009 02:50
> An: mapserver-users at lists.osgeo.org
> 
> 
Arnd Wippermann,

Thanks for your answer. I get your idea, but it does not work.
It said "map.getLayersBy(...) is null or not an object.
I want to ask in [map.getLayersBy("name", "querylayer")[0].visibility], what
is the "name"?
If I create a layer like that:
var ABC_layer = new OpenLayers.Layer.MapServer( "ABC WMS",  
"http://localhost/cgi-bin/mapserv.exe?map=c:/ms4w/Apache/htdocs/map.map&",
{layers: 'ABC'} );
The "name" is ABC WMS, ABC or ABC_layer?

Actually I have written in this way:
.....function (e) {
    if (ABC_layer.visibility == true) { 
    var url.....
It works but this part of codes only for one layer only. If there are many
layers, the html file would be looked clumsy.


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


More information about the mapserver-users mailing list