[OpenLayers-Users] GetFeatureInfo returns attribute nameonly(Mapserver & Openlayers)

Arnd Wippermann arnd.wippermann at web.de
Tue May 25 13:23:10 EDT 2010


Hi,

It's an issue with MapServer. If the returned html shows only "[NAME]" as in
the template, then it means, that MapServer couldn't resolve the tag.
Perhaps you have no column NAME in your data or it's an issue with upper and
lowercase.

Try

'wms_feature_info_mime_type' 'text/plain'
'wms_include_items'  'all'

To get the result with all attributes, that are availible.

Arnd

-----Ursprüngliche Nachricht-----
Von: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] Im
Auftrag von simi
Gesendet: Montag, 24. Mai 2010 10:14
An: users at openlayers.org
Betreff: [OpenLayers-Users] GetFeatureInfo returns attribute
nameonly(Mapserver & Openlayers)


I have been trying for a long time(since february 2010) to use
GetFeatureInfo to display the attributes of a clicked polygon feature . The
map is displayed in OpenLayers 2.8 which uses a mapserver 5.6.1 for the
mapfile whose data source is a shapefile. When i click on a polygon feature,
i only get the attribute name "[NAME]" (as it appears on the html body
template
file) AND not the atrribute values. Please help.Here is the openlayers file
contents;

<html>
<head><title>OpenLayers project</title>

<style type="text/css">
        #map {
            width: 800px;
            height: 600px;
            border: 1px solid black;
        }
    </style>

<script src="http://openlayers.org/api/OpenLayers.js"></script>
<script type="text/javascript">

function init() {

var map = new OpenLayers.Map('map');

var dcs = new OpenLayers.Layer.WMS(
'Admin Districts',
'http://localhost/cgi-bin/mapserv.exe?map=C:/ms4w/Apache/cgi-bin/Districts2.
map&',
{layers: 'Botswana_Admin_Districts'}
);


map.addLayer(dcs);


map.setCenter(new OpenLayers.LonLat(25,-24),6); 

// Tie click event to WMS GetFeatureInfo call        
map.events.register('click', map, function (e) {
    var url =
"http://localhost/cgi-bin/mapserv.exe?map=C:/ms4w/Apache/cgi-bin/Districts2.
map&" 
      + "?REQUEST=GetFeatureInfo"
      + "&EXCEPTIONS=application/vnd.ogc.se_xml"
      + "&BBOX=" + map.getExtent().toBBOX()
      + "&X=" + e.xy.x
      + "&Y=" + e.xy.y
      + "&INFO_FORMAT=text/html"
      + "&QUERY_LAYERS=Botswana_Admin_Districts"
      + "&LAYERS=Botswana_Admin_Districts"
      + "&FEATURE_COUNT=5"
      + "&SRS=EPSG:4326"
      + "&STYLES="
      + "&WIDTH=" + map.size.w
      + "&HEIGHT=" + map.size.h;
    window.open(url,
      "GetFeatureInfo",
      "location=0,status=0,scrollbars=1,width=600,height=150"
    );
  });
}


</script>
</head>
<body onload="init()">
<h2>OpenLayers Example</h2>
<div id='map'></div>
</body>
</html>



and the mapfile;


MAP
  NAME "Districts2"
  # Map image size
  SIZE 400 400
  UNITS dd
  EXTENT 15.807570 -27.131403 33.564789 -17.550001
  SHAPEPATH 'C:\ms4w\PSI_Shapefiles\'
  #FONTSET './fonts/fonts.txt'
  SYMBOLSET 'C:\ms4w\Apache\cgi-bin\Symbols.sym'
  PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
  END

  # Background color for the map canvas -- change as desired
  IMAGECOLOR 255 255 255
  IMAGEQUALITY 95
  IMAGETYPE agg

  OUTPUTFORMAT
    NAME agg
    DRIVER AGG/PNG
    IMAGEMODE RGB
  END
  
    
  # Legend
  LEGEND
      IMAGECOLOR 255 255 255
    STATUS ON
    KEYSIZE 18 12
    LABEL
      TYPE BITMAP
      SIZE MEDIUM
      COLOR 0 0 89
    END
  END

  # Web interface definition. Only the template parameter
  # is required to display a map. See MapServer documentation
  WEB
    # Set IMAGEPATH to the path where MapServer should
    # write its output.
    IMAGEPATH 'C:\ms4w\tmp\'

    # Set IMAGEURL to the url that points to IMAGEPATH
    # as defined in your web server configuration
    IMAGEURL '\tmp\'
    

    # WMS server settings
    METADATA
      wms_title           'QGIS-MAP'
      wms_onlineresource
'http://localhost/cgi-bin/mapserv.exe?map=C:/ms4w/Apache/cgi-bin/Districts2.
map&'
      wms_srs             'EPSG:4326'
	  wms_server_version '1.1.1'
      wms_feature_info_mime_type 'text/html'    
    
    END
    
    #Scale range at which web interface will operate
    # Template and header/footer settings
    # Only the template parameter is required to display a map. See
MapServer documentation
    HEADER 'http://localhost/Header.html'
	TEMPLATE 'http://localhost/Body.html'
    FOOTER 'http://localhost/Footer.html'
	
	END

  LAYER
    NAME 'Botswana_Admin_Districts'
    TYPE POLYGON
	TOLERANCE 10
	TOLERANCEUNITS pixels
    DUMP true
	HEADER 'http://localhost/Header.html'
    FOOTER 'http://localhost/Footer.html'
    EXTENT 15.807570 -27.131403 33.564789 -17.550001
    DATA Botswana_Admin_Districts
    METADATA
      wms_title 'Botswana_Admin_Districts'
	  wms_srs             'EPSG:4326'
      gml_include_items   'NAME'
      wms_include_items   'NAME'
	  wms_server_version '1.1.1'
      wms_name  'Botswana_Admin_Districts'
	  wms_feature_info_mime_type 'text/html'
	  gml_featureid 'OBJECTID'
    END
    
    STATUS ON
    TRANSPARENCY 100
    PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
    END
     
      
 CLASS
 TEMPLATE 'http://localhost/Body.html'
 
      OUTLINECOLOR "#C60F0F"
      COLOR 50 50 50
    END
  END
END

The template files;
The header,

<!-- 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 example</title>
  </head>
<body>
<table>
<tr>
<th>Name:</th>
</tr>

The body template file;

<!-- MapServer Template -->
<tr>
<td>[NAME]</td>
</tr>

and the Footer template file;


<!-- MapServer Template -->
</table>
</body>
</html> 


-- 
View this message in context:
http://osgeo-org.1803224.n2.nabble.com/GetFeatureInfo-returns-attribute-name
-only-Mapserver-Openlayers-tp5092982p5092982.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users




More information about the Users mailing list