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) {
|
if (poweredBy && poweredBy.parentNode) {
|
||||||
poweredBy.parentNode.removeChild(poweredBy);
|
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
|
* Method: loadMapObject
|
||||||
* Load the GMap and register appropriate event listeners. If we can't
|
* Load the GMap and register appropriate event listeners.
|
||||||
* load GMap2, then display a warning message.
|
|
||||||
*/
|
*/
|
||||||
loadMapObject:function() {
|
loadMapObject: function() {
|
||||||
if (!this.type) {
|
if (!this.type) {
|
||||||
this.type = google.maps.MapTypeId.ROADMAP;
|
this.type = google.maps.MapTypeId.ROADMAP;
|
||||||
}
|
}
|
||||||
@@ -92,7 +91,6 @@ OpenLayers.Layer.Google.v3 = {
|
|||||||
googleControl.style.width = '100%';
|
googleControl.style.width = '100%';
|
||||||
googleControl.style.height = '100%';
|
googleControl.style.height = '100%';
|
||||||
mapObject.controls[google.maps.ControlPosition.TOP_LEFT].push(googleControl);
|
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
|
// cache elements for use by any other google layers added to
|
||||||
// this same map
|
// this same map
|
||||||
@@ -141,13 +139,24 @@ OpenLayers.Layer.Google.v3 = {
|
|||||||
}
|
}
|
||||||
var container = this.mapObject.getDiv();
|
var container = this.mapObject.getDiv();
|
||||||
if (visible === true) {
|
if (visible === true) {
|
||||||
container.style.display = '';
|
if (container.parentNode !== map.div) {
|
||||||
cache.googleControl.appendChild(map.viewPortDiv);
|
if (!cache.rendered) {
|
||||||
google.maps.event.trigger(this.mapObject, 'resize');
|
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);
|
this.mapObject.setMapTypeId(type);
|
||||||
} else {
|
} else if (cache.googleControl.hasChildNodes()) {
|
||||||
map.div.appendChild(map.viewPortDiv);
|
map.div.appendChild(map.viewPortDiv);
|
||||||
container.style.display = 'none';
|
map.div.removeChild(container);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user