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.
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. |
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). |
Constants | |
EVENT_TYPES | |
Constructor | |
<OpenLayers. Control. WMSGetFeatureInfo> | |
Functions | |
activate | Activates the control. |
deactivate | Deactivates the control. |
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. |
{String} The click callback to register in the {OpenLayers.Handler.Click} object created when the hover option is set to false. Default is “click”.
{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.
{OpenLayers.Format} A format for parsing GetFeatureInfo responses. Default is OpenLayers.Format.WMSGetFeatureInfo.
{Object} Optional properties to set on the format (if one is not provided in the format property.
{Object} Reference to the OpenLayers.Handler for this control
{OpenLayers.Request} contains the currently running hover request (if any).
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. |
buildWMSOptions: function( url, layers, clickPosition, format )
Build an object with the relevant WMS options for the GetFeatureInfo request
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: function( layer )
Gets the STYLES parameter for the layer. Make sure the STYLES parameter matches the LAYERS parameter
layer | {OpenLayers.Layer.WMS} |
{Array(String)} The STYLES parameter
request: function( clickPosition, options )
Sends a GetFeatureInfo request to the WMS
clickPosition | {OpenLayers.Pixel} The position on the map where the mouse event occurred. |
options | {Object} additional options for this method. |
triggerGetFeatureInfo: function( request, xy, features )
Trigger the getfeatureinfo event when all is done
request | {XMLHttpRequest} The request object |
xy | {OpenLayers.Pixel} The position on the map where the mouse event occurred. |
features | {Array(OpenLayers.Feature.Vector)} |
handleResponse: function( xy, request )
Handler for the GetFeatureInfo response.
xy | {OpenLayers.Pixel} The position on the map where the mouse event occurred. |
request | {XMLHttpRequest} The request object. |
Activates the control.
activate: function ()
Deactivates the control.
deactivate: function ()
Called on click
getInfoForClick: function( evt )
Pause callback for the hover handler
getInfoForHover: function( evt )
Cancel callback for the hover handler
cancelHover: function()
Internal method to get the layers, independent of whether we are inspecting the map or using a client-provided array
findLayers: function()
Test to see if the provided url matches either the control url or one of the layerUrls.
urlMatches: function( url )
Build an object with the relevant WMS options for the GetFeatureInfo request
buildWMSOptions: function( url, layers, clickPosition, format )
Gets the STYLES parameter for the layer.
getStyleNames: function( layer )
Sends a GetFeatureInfo request to the WMS
request: function( clickPosition, options )
Trigger the getfeatureinfo event when all is done
triggerGetFeatureInfo: function( request, xy, features )
Handler for the GetFeatureInfo response.
handleResponse: function( xy, request )