Merge pull request #987 from ahocevar/google-orphaned
Vector layer duplicates when changeing to google base layer. r=@bartvde
This commit is contained in:
committed by
Bart van den Eijnden
parent
fe0620dc7f
commit
c2b7e8b327
@@ -274,6 +274,10 @@ OpenLayers.Layer.Google = OpenLayers.Class(
|
||||
if (poweredBy && poweredBy.parentNode) {
|
||||
poweredBy.parentNode.removeChild(poweredBy);
|
||||
}
|
||||
if (this.mapObject && window.google && google.maps &&
|
||||
google.maps.event && google.maps.event.clearListeners) {
|
||||
google.maps.event.clearListeners(this.mapObject, 'tilesloaded');
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -53,10 +53,9 @@ OpenLayers.Layer.Google.v3 = {
|
||||
|
||||
/**
|
||||
* Method: loadMapObject
|
||||
* Load the GMap and register appropriate event listeners. If we can't
|
||||
* load GMap2, then display a warning message.
|
||||
* Load the GMap and register appropriate event listeners.
|
||||
*/
|
||||
loadMapObject:function() {
|
||||
loadMapObject: function() {
|
||||
if (!this.type) {
|
||||
this.type = google.maps.MapTypeId.ROADMAP;
|
||||
}
|
||||
@@ -92,7 +91,6 @@ 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
|
||||
@@ -141,13 +139,24 @@ OpenLayers.Layer.Google.v3 = {
|
||||
}
|
||||
var container = this.mapObject.getDiv();
|
||||
if (visible === true) {
|
||||
container.style.display = '';
|
||||
cache.googleControl.appendChild(map.viewPortDiv);
|
||||
google.maps.event.trigger(this.mapObject, 'resize');
|
||||
if (container.parentNode !== map.div) {
|
||||
if (!cache.rendered) {
|
||||
var me = this;
|
||||
google.maps.event.addListenerOnce(this.mapObject, 'tilesloaded', function() {
|
||||
cache.rendered = true;
|
||||
me.setGMapVisibility(me.getVisibility());
|
||||
me.moveTo(me.map.getCenter());
|
||||
});
|
||||
} else {
|
||||
map.div.appendChild(container);
|
||||
cache.googleControl.appendChild(map.viewPortDiv);
|
||||
google.maps.event.trigger(this.mapObject, 'resize');
|
||||
}
|
||||
}
|
||||
this.mapObject.setMapTypeId(type);
|
||||
} else {
|
||||
} else if (cache.googleControl.hasChildNodes()) {
|
||||
map.div.appendChild(map.viewPortDiv);
|
||||
container.style.display = 'none';
|
||||
map.div.removeChild(container);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user