giving Layer.Google.v3 an animationEnabled option, like the one we already have for Layer.VirtualEarth. r=bartvde (closes #3020)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@11047 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
ahocevar
2011-01-20 13:31:30 +00:00
parent 3913ef1787
commit 3a16592b1a
3 changed files with 34 additions and 0 deletions

View File

@@ -19,6 +19,8 @@
</p>
<div id="map" class="smallmap"></div>
<div id="docs">
<p><input id="animate" type="checkbox" checked="checked">Animated
zoom (if supported by GMaps on your device)</input></p>
<p>
If you use the Google Maps v3 API with a Google layer, you don't
need to include an API key. This layer only works in the

View File

@@ -29,4 +29,12 @@ function init() {
new OpenLayers.Projection("EPSG:4326"),
map.getProjectionObject()
), 5);
// add behavior to html
var animate = document.getElementById("animate");
animate.onclick = function() {
for (var i=map.layers.length-1; i>=0; --i) {
map.layers[i].animationEnabled = this.checked;
}
};
}

View File

@@ -51,6 +51,19 @@ OpenLayers.Layer.Google.v3 = {
projection: "EPSG:900913"
},
/**
* APIProperty: animationEnabled
* {Boolean} If set to true, the transition between zoom levels will be
* animated (if supported by the GMaps API for the device used). Set to
* false to match the zooming experience of other layer types. Default
* is true. Note that the GMaps API does not give us control over zoom
* animation, so if set to false, when zooming, this will make the
* layer temporarily invisible, wait until GMaps reports the map being
* idle, and make it visible again. The result will be a blank layer
* for a few moments while zooming.
*/
animationEnabled: true,
/**
* Method: loadMapObject
* Load the GMap and register appropriate event listeners. If we can't
@@ -340,6 +353,17 @@ OpenLayers.Layer.Google.v3 = {
* zoom - {int} MapObject zoom format
*/
setMapObjectCenter: function(center, zoom) {
if (this.animationEnabled === false && zoom != this.mapObject.zoom) {
var mapContainer = this.getMapContainer();
google.maps.event.addListenerOnce(
this.mapObject,
"idle",
function() {
mapContainer.style.visibility = "";
}
);
mapContainer.style.visibility = "hidden";
}
this.mapObject.setOptions({
center: center,
zoom: zoom