# OpenLayers.Control.WMSGetFeatureInfo

The WMSGetFeatureInfo control uses a WMS query to get information about a point on the map. The information may be in a display-friendly format such as HTML, or a machine-friendly format such as GML, depending on the server’s capabilities and the client’s configuration. This control handles click or hover events, attempts to parse the results using an OpenLayers.Format, and fires a ‘getfeatureinfo’ event with the click position, the raw body of the response, and an array of features if it successfully read the response.

#### Inherits from

- OpenLayers.Control

Summary

OpenLayers.Control.WMSGetFeatureInfo | The WMSGetFeatureInfo control uses a WMS query to get information about a point on the map.
Properties |
hover | {Boolean} Send GetFeatureInfo requests when mouse stops moving.
drillDown | {Boolean} Drill down over all WMS layers in the map.
maxFeatures | {Integer} Maximum number of features to return from a WMS query.
clickCallback | {String} The click callback to register in the {OpenLayers.Handler.Click} object created when the hover option is set to false.
output | {String} Either “features” or “object”.
layers | {Array(OpenLayers.Layer.WMS)} The layers to query for feature info.
queryVisible | {Boolean} If true, filter out hidden layers when searching the map for layers to query.
url | {String} The URL of the WMS service to use.
layerUrls | {Array(String)} Optional list of urls for layers that should be queried.
infoFormat | {String} The mimetype to request from the server.
vendorParams | {Object} Additional parameters that will be added to the request, for WMS implementations that support them.
format | {OpenLayers.Format} A format for parsing GetFeatureInfo responses.
formatOptions | {Object} Optional properties to set on the format (if one is not provided in the format property.
handlerOptions | {Object} Additional options for the handlers used by this control, e.g.
handler | {Object} Reference to the OpenLayers.Handler for this control
hoverRequest | {OpenLayers.Request} contains the currently running hover request (if any).
events | {OpenLayers.Events} Events instance for listeners and triggering control specific events.
Constructor |
<OpenLayers.Control.WMSGetFeatureInfo> |
Functions |
getInfoForClick | Called on click
getInfoForHover | Pause callback for the hover handler
cancelHover | Cancel callback for the hover handler
findLayers | Internal method to get the layers, independent of whether we are inspecting the map or using a client-provided array
urlMatches | Test to see if the provided url matches either the control url or one of the layerUrls.
buildWMSOptions | Build an object with the relevant WMS options for the GetFeatureInfo request
getStyleNames | Gets the STYLES parameter for the layer.
request | Sends a GetFeatureInfo request to the WMS
triggerGetFeatureInfo | Trigger the getfeatureinfo event when all is done
handleResponse | Handler for the GetFeatureInfo response.

### Properties

### hover

{Boolean} Send GetFeatureInfo requests when mouse stops moving. Default is false.

### drillDown

{Boolean} Drill down over all WMS layers in the map. When using drillDown mode, hover is not possible, and an infoFormat that returns parseable features is required. Default is false.

### maxFeatures

{Integer} Maximum number of features to return from a WMS query. This sets the feature_count parameter on WMS GetFeatureInfo requests.

### clickCallback

{String} The click callback to register in the {OpenLayers.Handler.Click} object created when the hover option is set to false. Default is “click”.

### output

{String} Either “features” or “object”. When triggering a getfeatureinfo request should we pass on an array of features or an object with with a “features” property and other properties (such as the url of the WMS). Default is “features”.

### layers

{Array(OpenLayers.Layer.WMS)} The layers to query for feature info. If omitted, all map WMS layers with a url that matches this url or layerUrls will be considered.

### queryVisible

{Boolean} If true, filter out hidden layers when searching the map for layers to query. Default is false.

### url

{String} The URL of the WMS service to use. If not provided, the url of the first eligible layer will be used.

### layerUrls

{Array(String)} Optional list of urls for layers that should be queried. This can be used when the layer url differs from the url used for making GetFeatureInfo requests (in the case of a layer using cached tiles).

### infoFormat

{String} The mimetype to request from the server. If you are using drillDown mode and have multiple servers that do not share a common infoFormat, you can override the control’s infoFormat by providing an INFO_FORMAT parameter in your OpenLayers.Layer.WMS instance(s).

### vendorParams

{Object} Additional parameters that will be added to the request, for WMS implementations that support them. This could e.g. look like

>     {
>         radius: 5
>     }

### format

{OpenLayers.Format} A format for parsing GetFeatureInfo responses. Default is OpenLayers.Format.WMSGetFeatureInfo.

### formatOptions

{Object} Optional properties to set on the format (if one is not provided in the format property.

### handlerOptions

{Object} Additional options for the handlers used by this control, e.g.

>     {
>         "click": {delay: 100},
>         "hover": {delay: 300}
>     }

### handler

{Object} Reference to the OpenLayers.Handler for this control

### hoverRequest

{OpenLayers.Request} contains the currently running hover request (if any).

### events

{OpenLayers.Events} Events instance for listeners and triggering control specific events.

#### Register a listener for a particular event with the following syntax

>     control.events.register(type, obj, listener);

#### Supported event types (in addition to those from OpenLayers.Control.events)

beforegetfeatureinfo | Triggered before the request is sent. The event object has an xy property with the position of the mouse click or hover event that triggers the request.
nogetfeatureinfo | no queryable layers were found.
getfeatureinfo | Triggered when a GetFeatureInfo response is received. The event object has a text property with the body of the response (String), a features property with an array of the parsed features, an xy property with the position of the mouse click or hover event that triggered the request, and a request property with the request itself. If drillDown is set to true and multiple requests were issued to collect feature info from all layers, text and request will only contain the response body and request object of the last request.

### Constructor

### <OpenLayers.Control.WMSGetFeatureInfo>

#### Parameters

options | {Object}

### Functions

### getInfoForClick

> getInfoForClick: function( | evt | )

Called on click

#### Parameters

evt | {OpenLayers.Event}

### getInfoForHover

> getInfoForHover: function( | evt | )

Pause callback for the hover handler

#### Parameters

evt | {Object}

### cancelHover

> cancelHover: function()

Cancel callback for the hover handler

### findLayers

> findLayers: function()

Internal method to get the layers, independent of whether we are inspecting the map or using a client-provided array

### urlMatches

> urlMatches: function( | url | )

Test to see if the provided url matches either the control url or one of the layerUrls.

#### Parameters

url | {String} The url to test.

#### Returns

{Boolean} The provided url matches the control url or one of the layerUrls.

### buildWMSOptions

> buildWMSOptions: function( | url,
> | layers,
> | clickPosition,
> | format | )

Build an object with the relevant WMS options for the GetFeatureInfo request

#### Parameters

url | {String} The url to be used for sending the request
layers | {Array(<OpenLayers.Layer.WMS)} An array of layers
clickPosition | {OpenLayers.Pixel} The position on the map where the mouse event occurred.
format | {String} The format from the corresponding GetMap request

### getStyleNames

> getStyleNames: function( | layer | )

Gets the STYLES parameter for the layer. Make sure the STYLES parameter matches the LAYERS parameter

#### Parameters

layer | {OpenLayers.Layer.WMS}

#### Returns

{Array(String)} The STYLES parameter

### request

> request: function( | clickPosition,
> | options | )

Sends a GetFeatureInfo request to the WMS

#### Parameters

clickPosition | {OpenLayers.Pixel} The position on the map where the mouse event occurred.
options | {Object} additional options for this method.

#### Valid options

- hover {Boolean} true if we do the request for the hover handler

### triggerGetFeatureInfo

> triggerGetFeatureInfo: function( | request,
> | xy,
> | features | )

Trigger the getfeatureinfo event when all is done

#### Parameters

request | {XMLHttpRequest} The request object
xy | {OpenLayers.Pixel} The position on the map where the mouse event occurred.
features | {Array(OpenLayers.Feature.Vector)} or {Array({Object}) when output is “object”. The object has a url and a features property which contains an array of features.

### handleResponse

> handleResponse: function( | xy,
> | request,
> | url | )

Handler for the GetFeatureInfo response.

#### Parameters

xy | {OpenLayers.Pixel} The position on the map where the mouse event occurred.
request | {XMLHttpRequest} The request object.
url | {String} The url which was used for this request.

A handler for mouse clicks.
Instances of OpenLayers.Layer.WMS are used to display data from OGC Web Mapping Services.
Base class for format reading/writing a variety of formats.
{OpenLayers.Format} A format for parsing GetFeatureInfo responses.
Base class to construct a higher-level handler for event sequences.
The OpenLayers.Request namespace contains convenience methods for working with XMLHttpRequests.

> getInfoForClick: function( | evt | )

Called on click

> getInfoForHover: function( | evt | )

Pause callback for the hover handler

> cancelHover: function()

Cancel callback for the hover handler

> findLayers: function()

Internal method to get the layers, independent of whether we are inspecting the map or using a client-provided array

> urlMatches: function( | url | )

Test to see if the provided url matches either the control url or one of the layerUrls.
{String} The URL of the WMS service to use.
{Array(String)} Optional list of urls for layers that should be queried.

> buildWMSOptions: function( | url,
> | layers,
> | clickPosition,
> | format | )

Build an object with the relevant WMS options for the GetFeatureInfo request

> getStyleNames: function( | layer | )

Gets the STYLES parameter for the layer.

> request: function( | clickPosition,
> | options | )

Sends a GetFeatureInfo request to the WMS

> triggerGetFeatureInfo: function( | request,
> | xy,
> | features | )

Trigger the getfeatureinfo event when all is done

> handleResponse: function( | xy,
> | request,
> | url | )

Handler for the GetFeatureInfo response.
Controls affect the display or behavior of the map.
Class to read GetFeatureInfo responses from Web Mapping Services
{OpenLayers.Events} Events instance for listeners and triggering control specific events.
Utility functions for event handling.
This class represents a screen coordinate, in x and y coordinates
Vector features use the OpenLayers.Geometry classes as geometry description.
Close