[mapserver-users] WMSGetFeatureInfo problem

Karina Guardado kguardado at gmail.com
Mon Mar 12 13:38:50 PDT 2012


Hi Paolo,

Thank you very much for your help, Now it is working and I think now I
understand how do the Template work after looking at some examples and
creating 35 files even more. Here I mention some of the steps I follow so
maybe those can be helpfull for other people who probably have no idea
where to begin.

1. Download the last Openlayers version and copy into my folder and add a
link to the Openlayers.js

  <script type="text/javascript"
src="OpenLayers-2.11/lib/Firebug/firebug.js"></script>

 <script type="text/javascript"
src="OpenLayers-2.11/lib/OpenLayers.js"></script>

2. I added the  following code to my application in order to add the
WMSGetFeatureInfo Control

 toolbar.addControl(new OpenLayers.Control.WMSGetFeatureInfo({
                  url: '
http://mydomain/cgi-bin/mapserv?MAP=/var/www/myaddress/mymapfile.map&',
                  title: 'Identify features by clicking',
                  queryVisible: true,
                  infoFormat:'text/html',
                  click: 'true',
                  layers: [DepartamentosSRMSS, Municipios,
LimiteDepartamental],
                  eventListeners: {
                  getfeatureinfo: function(event) {
                  map.addPopup(new OpenLayers.Popup.FramedCloud(
                        "chicken",
                        map.getLonLatFromPixel(event.xy),
                        null,
                        event.text,
                        null,
                        true
                    ));
                   }
               }
             },{
            isDefault: true,
            title: 'Info'
        }),
        {
            iconCls: 'query',
            toggleGroup: 'map'
        });




3. I Created the layers like the one below

LAYER
    NAME 'Municipios'
    TYPE polygon
    DUMP true
    EXTENT 254093.5384 43485.4771 723948.4474 385070.6867
   CONNECTIONTYPE postgis
    CONNECTION "dbname='mydb' host=localhost port=5432 user='myuser'
password='mypassword' sslmode=disable"
    DATA 'the_geom FROM "SRMSSmunici" using unique gid using SRID=-1'
    HEADER   "templates/header.html"
    TEMPLATE "templates/content.html"
    FOOTER "templates/footer.html"
    METADATA
      'ows_title' 'SRMSSmunici'
      "wms_srs"   "epsg:8913 epsg:4326"
      'ows_geometries' 'the_geom'
      'wms_enable_request' '*'
      'wms_include_items' 'all'
      'ows_mygeom_type'  'polygon'
      "wms_feature_info_mime_type" "text/html"
       'queryable'          'true'
     "wms_enable_request" "GetMap GetFeatureInfo"

    END
    STATUS OFF
    TRANSPARENCY 100
    PROJECTION
         "init=epsg:8913"
      END
      CLASS
       NAME 'SRMSSmunici'
       STYLE
          WIDTH 2.4
        OUTLINECOLOR 115 0 0
       END
    END

  END


4.Create the  Template files

Header.html

<!-- MapServer Template -->
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/transitional.dtd">

 <html>

   <head>

     <!-- enforce the client to display result html as UTF-8 encoding -->

     <meta http-equiv="content-type" content="text/html;
charset=UTF-8"></meta>

     <title>GetFeatureInfo Response</title>


   </head>

   <body>
    <table>


Content.html

<!-- MapServer Template -->


       <caption>Layer: Arqueológico</caption>

       <tbody>

         <th >Nombre</th>

         <th >Sitio</th>

        <th  >Id</th>

      <tr >


       <td  >[item name="Nombre" format=$value escape=none]</td>

       <td >[item name="Sitio" format=$value escape=none]</td>

       <td >[item name="Id" format=$value escape=none]</td>

         </tr>

Footer.html

<!-- MapServer Template -->

       </tbody>

     </table>

     <br/>

   </body>

 </html>

On Thu, Mar 8, 2012 at 10:27 AM, Paolo Corti <pcorti at gmail.com> wrote:

> > But when i click on one point for example it is looking but doesn't shoe
> > anything and when looking at the fireburg result I found this
> >
> > msWMSFeatureInfo(): WMS server error. Unsupported INFO_FORMAT value
> > (text/html).
> >
> >
> >
> > I ask me if this is a problem with mapserver or with openlayers, any help
> > please.
>
> most likely you are missing the the wms_feature_info_mime_type
> metadata item  [1]:
> add "wms_feature_info_mime_type" "text/html" in the WEB/METADATA
> section of mapfile
>
> best regards
> P
>
> [1] http://mapserver.org/ogc/wms_server.html
> --
> Paolo Corti
> Geospatial software developer
> web: http://www.paolocorti.net
> twitter: @capooti
> skype: capooti
>



Best regards,

Karina Guardado
Geoinformatic
El Salvador
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20120312/7cb8e0c2/attachment.htm>


More information about the MapServer-users mailing list