From 059b83a52f2cea0adab49e1e3bfceafdffb3e037 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Mon, 27 Sep 2010 10:13:00 +0000 Subject: [PATCH] we get a js error in the Fixed strategy when the layer is removed from the map right after strategy.load is called, p=fvanderbiest, r=me (closes #2851) git-svn-id: http://svn.openlayers.org/trunk/openlayers@10791 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Strategy/Fixed.js | 32 ++++++++++--------- tests/Strategy/Fixed.html | 54 ++++++++++++++++++++++++++++++-- 2 files changed, 70 insertions(+), 16 deletions(-) diff --git a/lib/OpenLayers/Strategy/Fixed.js b/lib/OpenLayers/Strategy/Fixed.js index 0f77e256d5..6f758f6d1e 100644 --- a/lib/OpenLayers/Strategy/Fixed.js +++ b/lib/OpenLayers/Strategy/Fixed.js @@ -98,13 +98,14 @@ OpenLayers.Strategy.Fixed = OpenLayers.Class(OpenLayers.Strategy, { * options - {Object} options to pass to protocol read. */ load: function(options) { - this.layer.events.triggerEvent("loadstart"); - this.layer.protocol.read(OpenLayers.Util.applyDefaults({ - callback: this.merge, - filter: this.layer.filter, - scope: this + var layer = this.layer; + layer.events.triggerEvent("loadstart"); + layer.protocol.read(OpenLayers.Util.applyDefaults({ + callback: OpenLayers.Function.bind(this.merge, this, + layer.map.getProjectionObject()), + filter: layer.filter }, options)); - this.layer.events.un({ + layer.events.un({ "visibilitychanged": this.load, scope: this }); @@ -113,25 +114,28 @@ OpenLayers.Strategy.Fixed = OpenLayers.Class(OpenLayers.Strategy, { /** * Method: merge * Add all features to the layer. + * + * Parameters: + * mapProjection - {OpenLayers.Projection} the map projection + * resp - {Object} options to pass to protocol read. */ - merge: function(resp) { - this.layer.destroyFeatures(); + merge: function(mapProjection, resp) { + var layer = this.layer; + layer.destroyFeatures(); var features = resp.features; if (features && features.length > 0) { - var remote = this.layer.projection; - var local = this.layer.map.getProjectionObject(); - if(!local.equals(remote)) { + if(!mapProjection.equals(layer.projection)) { var geom; for(var i=0, len=features.length; i