Skip to content

Commit

Permalink
Make it safer to extend the Google Layer by not invoking Map.getLayer…
Browse files Browse the repository at this point in the history
…sByClass. Also removed an unused variable. tschaub made one more change to check for other Google layers only if we have a cache already - otherwise the whole logic would not apply anyway. Thanks iacovlev_pavel for bringing this up on IRC. p+r=tschaub,me (closes #2793)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@10632 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
  • Loading branch information
ahocevar committed Aug 18, 2010
1 parent 415fcbf commit 42fedc4
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions lib/OpenLayers/Layer/Google/v3.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,22 +181,20 @@ OpenLayers.Layer.Google.v3 = {
* visible - {Boolean} Display the GMap elements.
*/
setGMapVisibility: function(visible) {
var type = this.type;

var layers = this.map.getLayersByClass("OpenLayers.Layer.Google");
var index = OpenLayers.Util.indexOf(layers, this);
var layer;
for (var i=layers.length-1; i>=0; --i) {
layer = layers[i];
if (layer.visibility === true && layer.inRange === true) {
type = layer.type;
visible = true;
break;
}
}

var cache = OpenLayers.Layer.Google.cache[this.map.id];
if (cache) {
var type = this.type;
var layers = this.map.layers;
var layer;
for (var i=layers.length-1; i>=0; --i) {
layer = layers[i];
if (layer instanceof OpenLayers.Layer.Google &&
layer.visibility === true && layer.inRange === true) {
type = layer.type;
visible = true;
break;
}
}
var container = this.mapObject.getDiv();
if (visible === true) {
this.mapObject.setMapTypeId(type);
Expand Down

0 comments on commit 42fedc4

Please sign in to comment.