Skip to content

Commit

Permalink
Provide map and pixel location to callback.
Browse files Browse the repository at this point in the history
  • Loading branch information
tschaub committed Mar 4, 2012
1 parent 268b842 commit 32db586
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/OpenLayers/Control/UTFGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ OpenLayers.Control.UTFGrid = OpenLayers.Class(OpenLayers.Control, {
idx = OpenLayers.Util.indexOf(this.map.layers, layer);
infoLookup[idx] = layer.getFeatureInfo(lonLat);
}
this.callback(infoLookup); // perhaps pass tile, lonLat?
this.callback(infoLookup, lonLat, evt.xy);
}
},

Expand Down
13 changes: 7 additions & 6 deletions tests/Control/UTFGrid.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
});
log = [];
control = new OpenLayers.Control.UTFGrid({
callback: function(infoLookup) {
log.push(infoLookup);
callback: function(infoLookup, loc, pixel) {
log.push([infoLookup, loc, pixel]);
}
});
map.addControl(control);
Expand Down Expand Up @@ -68,7 +68,7 @@

var cases = [{
evt: {xy: {x: 100, y: 70}},
arg: {
lookup: {
"0": {
id: "207",
data: {
Expand All @@ -79,7 +79,7 @@
}
}, {
evt: {xy: {x: 350, y: 20}},
arg: {
lookup: {
"0": {
id: "245",
data: {
Expand All @@ -91,7 +91,7 @@
}];

var len = cases.length;
t.plan(3*len);
t.plan(4*len);

// wait for tile loading to finish
t.delay_call(0.5, function() {
Expand All @@ -101,7 +101,8 @@
t.eq(log.length, i, i + ": log length before");
control.handleEvent(c.evt);
t.eq(log.length, i+1, i + ": log length after");
t.eq(log[i], c.arg, i + ": callback arg");
t.eq(log[i][0], c.lookup, i + ": callback infoLookup");
t.eq(log[i][2], c.evt.xy, i + ": callback pixel");
}

tearDown();
Expand Down

0 comments on commit 32db586

Please sign in to comment.