Adding a WMTSGetFeatureInfo control for querying WMTS layers. r=ahocevar (closes #2678)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@10656 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2010-08-20 22:49:08 +00:00
parent 25fac24436
commit 3f172c501d
6 changed files with 945 additions and 0 deletions

View File

@@ -0,0 +1,69 @@
<!DOCTYPE html>
<html>
<head>
<title>OpenLayers WMTS GetFeatureInfo Example</title>
<link rel="stylesheet" href="../theme/default/style.css" type="text/css"/>
<link rel="stylesheet" href="style.css" type="text/css" />
<script src="../lib/Firebug/firebug.js"></script>
<script src="../lib/OpenLayers.js"></script>
<script src="wmts-getfeatureinfo.js"></script>
<style>
.olControlAttribution {
bottom: 5px;
}
table.featureInfo, table.featureInfo td, table.featureInfo th {
border: 1px solid #ddd;
border-collapse: collapse;
margin: 0;
padding: 0;
font-size: 80%;
padding: .1em .1em;
}
table.featureInfo th {
padding: .2em .2em;
font-weight: bold;
background: #eee;
}
table.featureInfo td {
background: #fff;
}
table.featureInfo tr.odd td {
background: #eee;
}
table.featureInfo caption {
text-align: left;
font-size: 100%;
font-weight: bold;
text-transform: uppercase;
padding: .1em .2em;
}
</style>
</head>
<body onload="init();">
<h1 id="title">WMTS GetFeatureInfo Control</h1>
<p id="shortdesc">
The WMTSGetFeatureInfo control allows retrieval of information about
features displayed in a WMTS layer.
</p>
<div id="map" class="smallmap"></div>
<input id="drill" type="checkbox" checked="checked">
<label for="drill">drill down</label>
<div id="docs">
<p>
This example uses an OpenLayers.Control.WMTSGetFeatureInfo
control layer to access information from WMTS layers. The
control is activated and configured to request feature
information when you click on the map. If the control's
drillDown property is set to true, multiple layers can be
queried.
</p><p>
See the <a href="wmts-getfeatureinfo.js" target="_blank">
wmts-getfeatureinfo.js source</a> to see how this is done.
</p>
</div>
</body>
</html>

View File

@@ -0,0 +1,99 @@
OpenLayers.ProxyHost = "/proxy/?url=";
var map, control, popups = {};
function init() {
map = new OpenLayers.Map({
div: "map",
projection: "EPSG:900913",
units: "m",
maxExtent: new OpenLayers.Bounds(
-20037508.34, -20037508.34, 20037508.34, 20037508.34
),
maxResolution: 156543.0339
});
var osm = new OpenLayers.Layer.OSM();
// If tile matrix identifiers differ from zoom levels (0, 1, 2, ...)
// then they must be explicitly provided.
var matrixIds = new Array(26);
for (var i=0; i<26; ++i) {
matrixIds[i] = "EPSG:900913:" + i;
}
var zoning = new OpenLayers.Layer.WMTS({
name: "zoning",
url: "http://v2.suite.opengeo.org/geoserver/gwc/service/wmts/",
layer: "medford:zoning",
matrixSet: "EPSG:900913",
matrixIds: matrixIds,
format: "image/png",
style: "_null",
opacity: 0.7,
isBaseLayer: false
});
var buildings = new OpenLayers.Layer.WMTS({
name: "building",
url: "http://v2.suite.opengeo.org/geoserver/gwc/service/wmts/",
layer: "medford:buildings",
matrixSet: "EPSG:900913",
matrixIds: matrixIds,
format: "image/png",
style: "_null",
isBaseLayer: false
});
map.addLayers([osm, zoning, buildings]);
// create WMTS GetFeatureInfo control
control = new OpenLayers.Control.WMTSGetFeatureInfo({
drillDown: true,
queryVisible: true,
eventListeners: {
getfeatureinfo: function(evt) {
var text;
var match = evt.text.match(/<body[^>]*>([\s\S]*)<\/body>/);
if (match && !match[1].match(/^\s*$/)) {
text = match[1];
} else {
text = "No " + evt.layer.name + " features in that area.<br>";
}
var popupId = evt.xy.x + "," + evt.xy.y;
var popup = popups[popupId];
if (!popup || !popup.map) {
popup = new OpenLayers.Popup.FramedCloud(
popupId,
map.getLonLatFromPixel(evt.xy),
null,
" ",
null,
true,
function(evt) {
delete popups[this.id];
this.hide();
OpenLayers.Event.stop(evt);
}
);
popups[popupId] = popup;
map.addPopup(popup, true);
}
popup.setContentHTML(popup.contentHTML + text);
popup.show();
}
}
});
map.addControl(control);
control.activate();
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.setCenter(new OpenLayers.LonLat(-13678519, 5212803), 15);
var drill = document.getElementById("drill");
drill.checked = true;
drill.onchange = function() {
control.drillDown = drill.checked;
};
}
OpenLayers.Popup.FramedCloud.prototype.maxSize = new OpenLayers.Size(350, 200);

View File

@@ -180,6 +180,7 @@
"OpenLayers/Control/NavigationHistory.js",
"OpenLayers/Control/Measure.js",
"OpenLayers/Control/WMSGetFeatureInfo.js",
"OpenLayers/Control/WMTSGetFeatureInfo.js",
"OpenLayers/Control/Graticule.js",
"OpenLayers/Control/TransformFeature.js",
"OpenLayers/Control/SLDSelect.js",

View File

@@ -0,0 +1,441 @@
/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
* license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
* full text of the license. */
/**
* @requires OpenLayers/Control.js
* @requires OpenLayers/Handler/Click.js
* @requires OpenLayers/Handler/Hover.js
* @requires OpenLayers/Request.js
* @requires OpenLayers/Format/WMSGetFeatureInfo.js
*/
/**
* Class: OpenLayers.Control.WMTSGetFeatureInfo
* The WMTSGetFeatureInfo control uses a WMTS 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 for each layer
* queried.
*
* Inherits from:
* - <OpenLayers.Control>
*/
OpenLayers.Control.WMTSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {
/**
* APIProperty: hover
* {Boolean} Send GetFeatureInfo requests when mouse stops moving.
* Default is false.
*/
hover: false,
/**
* Property: requestEncoding
* {String} One of "KVP" or "REST". Only KVP encoding is supported at this
* time.
*/
requestEncoding: "KVP",
/**
* APIProperty: drillDown
* {Boolean} Drill down over all WMTS layers in the map. When
* using drillDown mode, hover is not possible. A getfeatureinfo event
* will be fired for each layer queried.
*/
drillDown: false,
/**
* APIProperty: maxFeatures
* {Integer} Maximum number of features to return from a WMTS query. This
* sets the feature_count parameter on WMTS GetFeatureInfo
* requests.
*/
maxFeatures: 10,
/** APIProperty: 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".
*/
clickCallback: "click",
/**
* Property: layers
* {Array(<OpenLayers.Layer.WMTS>)} The layers to query for feature info.
* If omitted, all map WMTS layers will be considered.
*/
layers: null,
/**
* APIProperty: queryVisible
* {Boolean} Filter out hidden layers when searching the map for layers to
* query. Default is true.
*/
queryVisible: true,
/**
* Property: infoFormat
* {String} The mimetype to request from the server
*/
infoFormat: 'text/html',
/**
* Property: vendorParams
* {Object} Additional parameters that will be added to the request, for
* WMTS implementations that support them. This could e.g. look like
* (start code)
* {
* radius: 5
* }
* (end)
*/
vendorParams: {},
/**
* Property: format
* {<OpenLayers.Format>} A format for parsing GetFeatureInfo responses.
* Default is <OpenLayers.Format.WMSGetFeatureInfo>.
*/
format: null,
/**
* Property: formatOptions
* {Object} Optional properties to set on the format (if one is not provided
* in the <format> property.
*/
formatOptions: null,
/**
* APIProperty: handlerOptions
* {Object} Additional options for the handlers used by this control, e.g.
* (start code)
* {
* "click": {delay: 100},
* "hover": {delay: 300}
* }
* (end)
*/
handlerOptions: null,
/**
* Property: handler
* {Object} Reference to the <OpenLayers.Handler> for this control
*/
handler: null,
/**
* Property: hoverRequest
* {<OpenLayers.Request>} contains the currently running hover request
* (if any).
*/
hoverRequest: null,
/**
* Constant: EVENT_TYPES
*
* Supported event types (in addition to those from <OpenLayers.Control>):
* beforegetfeatureinfo - Triggered before each request is sent.
* The event object has an *xy* property with the position of the
* mouse click or hover event that triggers the request and a *layer*
* property referencing the layer about to be queried. If a listener
* returns false, the request will not be issued.
* 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, a *layer* property
* referencing the layer queried and a *request* property with the
* request itself. If drillDown is set to true, one event will be fired
* for each layer queried.
* exception - Triggered when a GetFeatureInfo request fails (with a
* status other than 200) or whenparsing fails. Listeners will receive
* an event with *request*, *xy*, and *layer* properties. In the case
* of a parsing error, the event will also contain an *error* property.
*/
EVENT_TYPES: ["beforegetfeatureinfo", "getfeatureinfo", "exception"],
/**
* Property: pending
* {Number} The number of pending requests.
*/
pending: 0,
/**
* Constructor: <OpenLayers.Control.WMTSGetFeatureInfo>
*
* Parameters:
* options - {Object}
*/
initialize: function(options) {
// concatenate events specific to vector with those from the base
this.EVENT_TYPES =
OpenLayers.Control.WMTSGetFeatureInfo.prototype.EVENT_TYPES.concat(
OpenLayers.Control.prototype.EVENT_TYPES
);
options = options || {};
options.handlerOptions = options.handlerOptions || {};
OpenLayers.Control.prototype.initialize.apply(this, [options]);
if (!this.format) {
this.format = new OpenLayers.Format.WMSGetFeatureInfo(
options.formatOptions
);
}
if (this.drillDown === true) {
this.hover = false;
}
if (this.hover) {
this.handler = new OpenLayers.Handler.Hover(
this, {
move: this.cancelHover,
pause: this.getInfoForHover
},
OpenLayers.Util.extend(
this.handlerOptions.hover || {}, {delay: 250}
)
);
} else {
var callbacks = {};
callbacks[this.clickCallback] = this.getInfoForClick;
this.handler = new OpenLayers.Handler.Click(
this, callbacks, this.handlerOptions.click || {}
);
}
},
/**
* Method: activate
* Activates the control.
*
* Returns:
* {Boolean} The control was effectively activated.
*/
activate: function () {
if (!this.active) {
this.handler.activate();
}
return OpenLayers.Control.prototype.activate.apply(
this, arguments
);
},
/**
* Method: deactivate
* Deactivates the control.
*
* Returns:
* {Boolean} The control was effectively deactivated.
*/
deactivate: function () {
return OpenLayers.Control.prototype.deactivate.apply(
this, arguments
);
},
/**
* Method: getInfoForClick
* Called on click
*
* Parameters:
* evt - {<OpenLayers.Event>}
*/
getInfoForClick: function(evt) {
this.request(evt.xy, {});
},
/**
* Method: getInfoForHover
* Pause callback for the hover handler
*
* Parameters:
* evt - {Object}
*/
getInfoForHover: function(evt) {
this.request(evt.xy, {hover: true});
},
/**
* Method: cancelHover
* Cancel callback for the hover handler
*/
cancelHover: function() {
if (this.hoverRequest) {
--this.pending;
if (this.pending <= 0) {
OpenLayers.Element.removeClass(this.map.viewPortDiv, "olCursorWait");
this.pending = 0;
}
this.hoverRequest.abort();
this.hoverRequest = null;
}
},
/**
* Method: findLayers
* Internal method to get the layers, independent of whether we are
* inspecting the map or using a client-provided array
*/
findLayers: function() {
var candidates = this.layers || this.map.layers;
var layers = [];
var layer;
for (var i=candidates.length-1; i>=0; --i) {
layer = candidates[i];
if (layer instanceof OpenLayers.Layer.WMTS &&
layer.requestEncoding === this.requestEncoding &&
(!this.queryVisible || layer.getVisibility())) {
layers.push(layer);
if (!this.drillDown || this.hover) {
break;
}
}
}
return layers;
},
/**
* Method: buildRequestOptions
* Build an object with the relevant options for the GetFeatureInfo request.
*
* Parameters:
* layer - {<OpenLayers.Layer.WMTS>} A WMTS layer.
* xy - {<OpenLayers.Pixel>} The position on the map where the
* mouse event occurred.
*/
buildRequestOptions: function(layer, xy) {
var loc = this.map.getLonLatFromPixel(xy);
var getTileUrl = layer.getURL(
new OpenLayers.Bounds(loc.lon, loc.lat, loc.lon, loc.lat)
);
var params = OpenLayers.Util.getParameters(getTileUrl);
var tileInfo = layer.getTileInfo(loc);
OpenLayers.Util.extend(params, {
service: "WMTS",
version: layer.version,
request: "GetFeatureInfo",
infoFormat: this.infoFormat,
i: tileInfo.i,
j: tileInfo.j
});
OpenLayers.Util.applyDefaults(params, this.vendorParams);
return {
url: layer.url instanceof Array ? layer.url[0] : layer.url,
params: OpenLayers.Util.upperCaseObject(params),
callback: function(request) {
this.handleResponse(xy, request, layer);
},
scope: this
};
},
/**
* Method: request
* Sends a GetFeatureInfo request to the WMTS
*
* Parameters:
* xy - {<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
*/
request: function(xy, options) {
options = options || {};
var layers = this.findLayers();
if (layers.length > 0) {
var issue, layer;
for (var i=0, len=layers.length; i<len; i++) {
layer = layers[i];
issue = this.events.triggerEvent("beforegetfeatureinfo", {
xy: xy,
layer: layer
});
if (issue !== false) {
++this.pending;
var requestOptions = this.buildRequestOptions(layer, xy);
var request = OpenLayers.Request.GET(requestOptions);
if (options.hover === true) {
this.hoverRequest = request;
}
}
}
if (this.pending > 0) {
OpenLayers.Element.addClass(this.map.viewPortDiv, "olCursorWait");
}
}
},
/**
* Method: handleResponse
* Handler for the GetFeatureInfo response.
*
* Parameters:
* xy - {<OpenLayers.Pixel>} The position on the map where the mouse event
* occurred.
* request - {XMLHttpRequest} The request object.
* layer - {<OpenLayers.Layer.WMTS>} The queried layer.
*/
handleResponse: function(xy, request, layer) {
--this.pending;
if (this.pending <= 0) {
OpenLayers.Element.removeClass(this.map.viewPortDiv, "olCursorWait");
this.pending = 0;
}
if (request.status && (request.status < 200 || request.status >= 300)) {
this.events.triggerEvent("exception", {
xy: xy,
request: request,
layer: layer
});
} else {
var doc = request.responseXML;
if (!doc || !doc.documentElement) {
doc = request.responseText;
}
var features, except;
try {
features = this.format.read(doc);
} catch (error) {
except = true;
this.events.triggerEvent("exception", {
xy: xy,
request: request,
error: error,
layer: layer
});
}
if (!except) {
this.events.triggerEvent("getfeatureinfo", {
text: request.responseText,
features: features,
request: request,
xy: xy,
layer: layer
});
}
}
},
/**
* Method: setMap
* Set the map property for the control.
*
* Parameters:
* map - {<OpenLayers.Map>}
*/
setMap: function(map) {
this.handler.setMap(map);
OpenLayers.Control.prototype.setMap.apply(this, arguments);
},
CLASS_NAME: "OpenLayers.Control.WMTSGetFeatureInfo"
});

View File

@@ -0,0 +1,334 @@
<html>
<head>
<script src="../../lib/OpenLayers.js"></script>
<script type="text/javascript">
function test_initialize(t) {
t.plan(4);
var options = {
url: "http://localhost/wmts",
layers: ["foo"],
formatOptions: {
foo: "bar"
}
};
var control = new OpenLayers.Control.WMTSGetFeatureInfo(options);
t.ok(control instanceof OpenLayers.Control.WMTSGetFeatureInfo,
"new OpenLayers.Control.WMTSGetFeatureInfo returns an instance");
t.eq(control.layers, ["foo"],
"constructor layers"
);
t.ok(control.format instanceof OpenLayers.Format.WMSGetFeatureInfo, "format created");
t.eq(control.format.foo, "bar", "format options used")
}
function test_clickCallBack_option(t) {
t.plan(9);
var control;
control = new OpenLayers.Control.WMTSGetFeatureInfo({
hover: true
});
t.ok(control.handler instanceof OpenLayers.Handler.Hover,
'constructor creates hover handler');
t.ok(control.handler.callbacks["move"] === control.cancelHover,
'constructor registers proper "move" callback in handler');
t.ok(control.handler.callbacks["pause"] === control.getInfoForHover,
'constructor registers proper "pause" callback in handler');
control = new OpenLayers.Control.WMTSGetFeatureInfo();
t.ok(control.handler instanceof OpenLayers.Handler.Click,
'constructor creates click handler');
t.ok(control.handler.callbacks["click"] === control.getInfoForClick,
'constructor registers proper "click" callback in handler');
control = new OpenLayers.Control.WMTSGetFeatureInfo({
clickCallback: "rightclick"
});
t.ok(control.handler.callbacks["rightclick"] === control.getInfoForClick,
'constructor registers proper "rightclick" callback in handler');
control = new OpenLayers.Control.WMTSGetFeatureInfo({
clickCallback: "dblclick",
handlerOptions: {
click: {
"single": false,
"double": true
}
}
});
t.ok(control.handler.callbacks["dblclick"] === control.getInfoForClick,
'constructor registers proper "dblclick" callback in handler');
t.eq(control.handler["single"], false,
'constructor sets "single" to false in handler');
t.eq(control.handler["double"], true,
'constructor sets "double" to true in handler');
}
function test_destroy(t) {
t.plan(2);
var map = new OpenLayers.Map("map");
var click = new OpenLayers.Control.WMTSGetFeatureInfo({
url: 'http://localhost/wms',
layers: ["foo"]
});
var hover = new OpenLayers.Control.WMTSGetFeatureInfo({
url: 'http://localhost/wms',
layers: ["foo"],
hover: true
});
click.handler.deactivate = function() {
t.ok(true,
"control.deactivate calls deactivate on click handler");
};
hover.handler.deactivate = function() {
t.ok(true,
"control.deactivate calls deactivate on hover handler");
};
click.destroy();
hover.destroy();
}
function test_click(t) {
t.plan(4);
var map = new OpenLayers.Map('map');
// mock up active control
var control = new OpenLayers.Control.WMTSGetFeatureInfo();
map.addControl(control);
control.activate();
control.request = function(position) {
t.eq(position.x, 200,
"x position is as expected");
t.eq(position.y, 125,
"y position is as expected");
};
control.getInfoForClick({xy: {x: 200, y: 125}});
control.getInfoForHover({xy: {x: 200, y: 125}});
}
function test_beforegetfeatureinfo_event(t) {
t.plan(2);
var map = new OpenLayers.Map({
div: "map",
allOverlays: true,
layers: [
new OpenLayers.Layer.WMTS({
name: "Test WMTS 1",
url: "/testwmts/",
layer: "test1",
style: "",
matrixSet: "set-id",
isBaseLayer: false
}),
new OpenLayers.Layer.WMTS({
name: "Test WMTS 2",
url: "/testwmts/",
layer: "test2",
style: "",
matrixSet: "set-id",
isBaseLayer: false
})
],
center: new OpenLayers.LonLat(0, 0),
zoom: 0
});
var log = [];
// test click
var click = new OpenLayers.Control.WMTSGetFeatureInfo({
drillDown: true,
eventListeners: {
beforegetfeatureinfo: function(evt) {
log.push({xy: evt.xy});
}
}
});
map.addControl(click);
click.activate();
click.getInfoForClick({xy: {x: 200, y: 125}});
t.eq(log.length, 2, "click: beforegetfeatureinfo triggered twice");
log = [];
click.deactivate();
// test hover
var hover = new OpenLayers.Control.WMTSGetFeatureInfo({
hover: true,
eventListeners: {
beforegetfeatureinfo: function(evt) {
log.push({xy: evt.xy});
}
}
});
map.addControl(hover);
hover.activate();
xy = {x: 70, y: 70};
hover.getInfoForHover({xy: {x: 70, y: 70}});
t.eq(log.length, 1, "hover: beforegetfeatureinfo triggered once");
log = [];
hover.deactivate();
map.destroy();
}
function test_activate(t) {
t.plan(4);
var map = new OpenLayers.Map("map");
var click = new OpenLayers.Control.WMTSGetFeatureInfo({
url: 'http://localhost/wms',
layers: ['ns:type']
});
var hover = new OpenLayers.Control.WMTSGetFeatureInfo({
url: 'http://localhost/wms',
featureType: 'type',
featureNS: 'http://localhost/ns',
layers: 'ns:type',
hover: true
});
map.addControl(click);
map.addControl(hover);
t.ok(!click.handler.active,
"click handler is not active prior to activating control");
t.ok(!hover.handler.active,
"hover handler is not active prior to activating control");
click.activate();
hover.activate();
t.ok(click.handler.active,
"click handler is active after activating control");
t.ok(hover.handler.active,
"hover handler is active after activating control");
}
function test_deactivate(t) {
t.plan(2);
var map = new OpenLayers.Map("map");
var click = new OpenLayers.Control.WMTSGetFeatureInfo({
url: 'http://localhost/wms',
featureType: 'type',
featureNS: 'http://localhost/ns',
layers: 'ns:type'
});
var hover = new OpenLayers.Control.WMTSGetFeatureInfo({
url: 'http://localhost/wms',
featureType: 'type',
featureNS: 'http://localhost/ns',
layers: 'ns:type'
});
map.addControl(click);
map.addControl(hover);
click.activate();
hover.activate();
click.handler.deactivate = function() {
t.ok(true,
"control.deactivate calls deactivate on click handler");
OpenLayers.Handler.Click.prototype.deactivate.apply(this, arguments);
};
hover.handler.deactivate = function() {
t.ok(true,
"control.deactivate calls deactivate on hover handler");
OpenLayers.Handler.Hover.prototype.deactivate.apply(this, arguments);
};
click.deactivate();
hover.deactivate();
}
function test_getInfoForClick(t) {
t.plan(13);
var map = new OpenLayers.Map({
div: "map",
getExtent: function() {
return new OpenLayers.Bounds(-180,-90,180,90);
}
});
var a = new OpenLayers.Layer.WMTS({
url: "http://a.example.com/wmts",
layer: "a",
matrixSet: "bar",
style: "default"
});
var b = new OpenLayers.Layer.WMTS({
url: "http://b.example.com/wmts",
layer: "b",
matrixSet: "bar",
style: "default",
isBaseLayer: false
});
var c = new OpenLayers.Layer.WMTS({
url: ["http://c1.example.com/wmts", "http://c2.example.com"],
layer: "c",
matrixSet: "bar",
style: "default",
isBaseLayer: false
});
map.addLayers([a, b, c]);
map.zoomToMaxExtent();
var control = new OpenLayers.Control.WMTSGetFeatureInfo({
layers: [a, b, c]
});
map.addControl(control);
control.activate();
// log calls to GET
var log;
var _request = OpenLayers.Request.GET;
OpenLayers.Request.GET = function(options) {
log.push(options);
};
// query first layer (drillDown false)
log = [];
control.drillDown = false;
control.queryVisible = false;
control.getInfoForClick({xy: {x: 200, y: 125}});
t.eq(log.length, 1, "one requests issued");
t.eq(log[0].url, "http://c1.example.com/wmts", "{drillDown: false} correct url");
t.eq(log[0].params["LAYER"], "c", "{drillDown: false} correct layer parameter");
// query all layers
log = [];
control.drillDown = true;
control.queryVisible = false;
control.getInfoForClick({xy: {x: 200, y: 125}});
t.eq(log.length, 3, "three requests issued");
t.eq(log[0].url, "http://c1.example.com/wmts", "[c] correct url");
t.eq(log[0].params["LAYER"], "c", "[c] correct layer parameter");
t.eq(log[1].url, "http://b.example.com/wmts", "[b] correct url");
t.eq(log[1].params["LAYER"], "b", "[b] correct layer parameter");
t.eq(log[2].url, "http://a.example.com/wmts", "[a] correct url");
t.eq(log[2].params["LAYER"], "a", "[a] correct layer parameter");
// query only visible layers
log = [];
control.drillDown = true;
control.queryVisible = true;
b.setVisibility(false);
control.getInfoForClick({xy: {x: 200, y: 125}});
t.eq(log.length, 2, "two requests issued");
t.eq(log[0].url, "http://c1.example.com/wmts", "correct url for second visible layer");
t.eq(log[1].url, "http://a.example.com/wmts", "correct url for first visible layer");
// clean up
OpenLayers.Request.GET = _request;
map.destroy();
}
</script>
</head>
<body>
<div id="map" style="width: 400px; height: 250px;"/>
</body>
</html>

View File

@@ -37,6 +37,7 @@
<li>Control/Split.html</li>
<li>Control/TransformFeature.html</li>
<li>Control/WMSGetFeatureInfo.html</li>
<li>Control/WMTSGetFeatureInfo.html</li>
<li>Control/PanPanel.html</li>
<li>Control/SLDSelect.html</li>
<li>Events.html</li>