Compare commits

..

2 Commits

Author SHA1 Message Date
crschmidt
9f31355310 tag rc5
git-svn-id: http://svn.openlayers.org/tags/openlayers/release-2.8-rc5@9424 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2009-06-02 15:51:37 +00:00
crschmidt
d25037210a Pullups for 2.8 RC5:
Google Layer resizing (Closes #1797)
 SelectFeature default scope (Closes #2115)


git-svn-id: http://svn.openlayers.org/branches/openlayers/2.8@9423 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2009-06-02 15:50:30 +00:00
3 changed files with 12 additions and 6 deletions

View File

@@ -111,7 +111,7 @@ OpenLayers.Control.SelectFeature = OpenLayers.Class(OpenLayers.Control, {
* {Object} The scope to use with the onBeforeSelect, onSelect, onUnselect * {Object} The scope to use with the onBeforeSelect, onSelect, onUnselect
* callbacks. If null the scope will be this control. * callbacks. If null the scope will be this control.
*/ */
scope: this, scope: null,
/** /**
* APIProperty: geometryTypes * APIProperty: geometryTypes
@@ -178,6 +178,10 @@ OpenLayers.Control.SelectFeature = OpenLayers.Class(OpenLayers.Control, {
OpenLayers.Control.prototype.EVENT_TYPES OpenLayers.Control.prototype.EVENT_TYPES
); );
OpenLayers.Control.prototype.initialize.apply(this, [options]); OpenLayers.Control.prototype.initialize.apply(this, [options]);
if(this.scope === null) {
this.scope = this;
}
if(layers instanceof Array) { if(layers instanceof Array) {
this.layers = layers; this.layers = layers;
this.layer = new OpenLayers.Layer.Vector.RootContainer( this.layer = new OpenLayers.Layer.Vector.RootContainer(

View File

@@ -213,7 +213,7 @@ OpenLayers.Layer.Google = OpenLayers.Class(
*/ */
onMapResize: function() { onMapResize: function() {
// workaround for resizing of invisible or not yet fully loaded layers // workaround for resizing of invisible or not yet fully loaded layers
// where GMap2.checkResize() does not work. We need to load all tiles // where GMap2.checkResize() does not work. We need to load the GMap
// for the old div size, then checkResize(), and then call // for the old div size, then checkResize(), and then call
// layer.moveTo() to trigger GMap.setCenter() (which will finish // layer.moveTo() to trigger GMap.setCenter() (which will finish
// the GMap initialization). // the GMap initialization).
@@ -222,7 +222,7 @@ OpenLayers.Layer.Google = OpenLayers.Class(
} else { } else {
if(!this._resized) { if(!this._resized) {
var layer = this; var layer = this;
var handle = GEvent.addListener(this.mapObject, "tilesloaded", function() { var handle = GEvent.addListener(this.mapObject, "load", function() {
GEvent.removeListener(handle); GEvent.removeListener(handle);
delete layer._resized; delete layer._resized;
layer.mapObject.checkResize(); layer.mapObject.checkResize();

View File

@@ -68,7 +68,7 @@
} }
function test_Control_SelectFeature_clickFeature(t) { function test_Control_SelectFeature_clickFeature(t) {
t.plan(4); t.plan(6);
// mock up layer // mock up layer
var layer = { var layer = {
selectedFeatures: [], selectedFeatures: [],
@@ -100,6 +100,7 @@
"onSelect called with proper feature (" + feature.index + ")"); "onSelect called with proper feature (" + feature.index + ")");
t.eq(feature.tested, feature.test, t.eq(feature.tested, feature.test,
"onSelect called only once for feature (" + feature.index + ")"); "onSelect called only once for feature (" + feature.index + ")");
t.ok(this == control, "onSelect called in the scope of the control if control.scope is not provided");
} }
// test that onUnselect gets called properly // test that onUnselect gets called properly
@@ -109,9 +110,10 @@
"onUnselect called with proper feature (" + feature.index + ")"); "onUnselect called with proper feature (" + feature.index + ")");
t.eq(feature.tested, feature.test, t.eq(feature.tested, feature.test,
"onUnselect called only once for feature (" + feature.index + ")"); "onUnselect called only once for feature (" + feature.index + ")");
t.ok(this == control, "onUnselect called in the scope of the control if control.scope is not provided");
} }
// mock up first click on first feature (runs 2 tests from onSelect) // mock up first click on first feature (runs 3 tests from onSelect)
var feature = features[0]; var feature = features[0];
feature.index = 0; feature.index = 0;
feature.test = 1; feature.test = 1;
@@ -121,7 +123,7 @@
control.toggle = false; control.toggle = false;
control.clickFeature(feature); control.clickFeature(feature);
// mock up second click on first feature (runs 2 tests from onUnselect) // mock up second click on first feature (runs 3 tests from onUnselect)
control.toggle = true; control.toggle = true;
feature.test = 2; feature.test = 2;
control.clickFeature(feature); control.clickFeature(feature);