diff --git a/lib/OpenLayers/Layer/Google/v3.js b/lib/OpenLayers/Layer/Google/v3.js index a70c7bbf13..10c3e856c5 100644 --- a/lib/OpenLayers/Layer/Google/v3.js +++ b/lib/OpenLayers/Layer/Google/v3.js @@ -92,6 +92,7 @@ OpenLayers.Layer.Google.v3 = { googleControl.style.width = '100%'; googleControl.style.height = '100%'; mapObject.controls[google.maps.ControlPosition.TOP_LEFT].push(googleControl); + this.map.div.appendChild(container); // cache elements for use by any other google layers added to // this same map @@ -140,26 +141,13 @@ OpenLayers.Layer.Google.v3 = { } var container = this.mapObject.getDiv(); if (visible === true) { - if (container.parentNode !== map.div) { - map.div.appendChild(container); - if (!cache.rendered) { - google.maps.event.addListenerOnce(this.mapObject, 'tilesloaded', function() { - cache.googleControl.appendChild(map.viewPortDiv); - cache.rendered = true; - }); - } else { - cache.googleControl.appendChild(map.viewPortDiv); - } - google.maps.event.trigger(this.mapObject, 'resize'); - } + container.style.display = ''; + cache.googleControl.appendChild(map.viewPortDiv); + google.maps.event.trigger(this.mapObject, 'resize'); this.mapObject.setMapTypeId(type); - cache.displayed = this.id; } else { - if (cache.googleControl.hasChildNodes()) { - map.div.appendChild(map.viewPortDiv); - map.div.removeChild(container); - } - delete cache.displayed; + map.div.appendChild(map.viewPortDiv); + container.style.display = 'none'; } } },