[mapserver-users] Query feature using openlayers and mapserver
Aypes
apestgas at yahoo.com.hk
Thu Oct 29 18:33:46 PDT 2009
P Kishor wrote:
>
> On Thu, Oct 29, 2009 at 1:13 AM, Aypes <apestgas at yahoo.com.hk> wrote:
> Here is how I did it, and it worked for me (test for typing errors)
>
> Step 1: In the map file
>
> Step 1a: WEB
>
> WEB
> ,,
>
> # WMS server settings
> METADATA
> ..
> "wms_feature_info_mime_type" "text/html"
> END
> END # WEB
>
> Step 1b: LAYER to be queried
>
> LAYER
> NAME 'layer_name'
> ..
>
> METADATA
> ..
> 'wms_include_items' "FiEld_NaMe" # field name is possibly
> # case-sensitive in the
> case of
> # shape files
> END # METADATA
>
> DUMP true
> HEADER "/absolute/path/to/template_header.html"
> TEMPLATE "/absolute/path/to/template_body.html"
> FOOTER "/absolute/path/to/template_footer.html"
> END # LAYER
>
> Step 2: In your HTML templates
>
> Step 2a: in template_header.html
>
> <!-- MapServer Template -->
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> "http://www.w3.org/TR/html4/transitional.dtd">
> <html>
> <head>
> <title>MapServer Template Sample</title>
> </head>
>
> Step 2b: in template_body.html
>
> <body>
> FiEld_NaMe: [FiEld_NaMe]
> </body>
>
> Step 2c: in template_footer.html
>
> </html>
>
> Step 3: In your HTML file with OpenLayers code
>
> map.addControl(
> new OpenLayers.Control.WMSGetFeatureInfo(
> function() {
> return {
> url: "/url/to/mapserv",
> maxFeatures: 1,
> title: 'Identify features by clicking',
> queryVisible: true,
> layers: [layer_name],
> vendorParams: {
> map: "/absolute/path/to/mapfile"
> },
> eventListeners: {
> getfeatureinfo: function(event) {
> map.addPopup(
> new OpenLayers.Popup.FramedCloud(
> "chicken",
> map.getLonLatFromPixel(event.xy),
> null,
> event.text,
> null,
> true
> ),
> true
> ); // map.addPopup
> } // getfeatureinfo
> } // eventListeners
> } // return
> }
> )
> ).activate();
>
>
>
> --
> Puneet Kishor http://www.punkish.org
> Carbon Model http://carbonmodel.org
> Charter Member, Open Source Geospatial Foundation http://www.osgeo.org
> Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor
> Nelson Institute, UW-Madison http://www.nelson.wisc.edu
> -----------------------------------------------------------------------
> Assertions are politics; backing up assertions with evidence is science
> =======================================================================
> Sent from Madison, WI, United States
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>
>
P Kishor,
Thank you for answering. But I have some problems.
I want to know that in map file, [TEMPLATE
"/absolute/path/to/template_body.html"] is ouside or inside the class of the
layer?
Secondly, for the part
map.addPopup(
new OpenLayers.Popup.FramedCloud( "chicken",
map.getLonLatFromPixel(event.xy), null, event.text, null,
true)
I just do not understand the structure of it even though I have searched it
on Internet. Should "chicken" change to the layer name, and where/what is
event.txt?
Thirdly there is some problem on activate(). I got an error of
'map.addControl(...)' is null or not an object. If I detele activate(), it
works without the getfeatureinfo property. But I have no idea on how to
activate it.
And I am using OpenLayers.layer.Mapserver to render map, not
OperLayers.layer.WMS. Does new OpenLayers.Control. WMSGetFeatureInfo still
work?
Thanks,
Aypes
--
View this message in context: http://n2.nabble.com/Query-feature-using-openlayers-and-mapserver-tp3910093p3916619.html
Sent from the Mapserver - User mailing list archive at Nabble.com.
More information about the MapServer-users
mailing list