Properly setting the hoverRequest so it can be aborted. r=ahocevar (closes #2797)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@10649 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -433,10 +433,10 @@ OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {
|
|||||||
if(this.drillDown === false) {
|
if(this.drillDown === false) {
|
||||||
var wmsOptions = this.buildWMSOptions(this.url, layers,
|
var wmsOptions = this.buildWMSOptions(this.url, layers,
|
||||||
clickPosition, layers[0].params.FORMAT);
|
clickPosition, layers[0].params.FORMAT);
|
||||||
var response = OpenLayers.Request.GET(wmsOptions);
|
var request = OpenLayers.Request.GET(wmsOptions);
|
||||||
|
|
||||||
if (options.hover === true) {
|
if (options.hover === true) {
|
||||||
this.hoverRequest = response.priv;
|
this.hoverRequest = request;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this._requestCount = 0;
|
this._requestCount = 0;
|
||||||
|
|||||||
@@ -351,6 +351,42 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function test_hover(t) {
|
||||||
|
|
||||||
|
t.plan(2);
|
||||||
|
|
||||||
|
var map = new OpenLayers.Map({
|
||||||
|
div: "map",
|
||||||
|
layers: [
|
||||||
|
new OpenLayers.Layer.WMS(null, "/dummywms", {layers: "one"})
|
||||||
|
],
|
||||||
|
center: new OpenLayers.LonLat(0, 0),
|
||||||
|
zoom: 1
|
||||||
|
});
|
||||||
|
|
||||||
|
var control = new OpenLayers.Control.WMSGetFeatureInfo({
|
||||||
|
hover: true
|
||||||
|
});
|
||||||
|
map.addControl(control);
|
||||||
|
control.activate();
|
||||||
|
|
||||||
|
// mock up a mousemove
|
||||||
|
control.getInfoForHover({xy: new OpenLayers.Pixel(10, 10)});
|
||||||
|
t.ok(!!control.hoverRequest, "hoverRequest set");
|
||||||
|
|
||||||
|
// confirm that request is canceled on next move
|
||||||
|
var called = 0;
|
||||||
|
control.hoverRequest.abort = function() {
|
||||||
|
++called;
|
||||||
|
};
|
||||||
|
control.handler.px = null;
|
||||||
|
control.handler.mousemove({xy: new OpenLayers.Pixel(20, 20)});
|
||||||
|
t.eq(called, 1, "hover request aborted");
|
||||||
|
|
||||||
|
map.destroy();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function test_drillDown(t) {
|
function test_drillDown(t) {
|
||||||
t.plan(4);
|
t.plan(4);
|
||||||
var map = new OpenLayers.Map("map", {
|
var map = new OpenLayers.Map("map", {
|
||||||
|
|||||||
Reference in New Issue
Block a user