panmethod option on map to allow for the turning off of animated panning.

Includes example. All tests pass. r=tschaub. (Closes #1356)


git-svn-id: http://svn.openlayers.org/trunk/openlayers@6411 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2008-02-29 06:03:12 +00:00
parent 6ff86dc756
commit 5f93cc2b52
2 changed files with 29 additions and 4 deletions

View File

@@ -8,6 +8,11 @@
height: 256px;
border: 1px solid black;
}
#map2 {
width: 512px;
height: 256px;
border: 1px solid black;
}
</style>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
@@ -50,6 +55,13 @@
map.addControl(click);
click.activate();
map.addControl(new OpenLayers.Control.OverviewMap());
map2 = new OpenLayers.Map('map2', {'panMethod': null} );
layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
map2.addLayer(layer);
map2.zoomToMaxExtent();
}
function setCenterInterval() {
@@ -76,11 +88,16 @@
<div id="shortdesc">Show animated panning effects in the map</div>
<div id="map"></div>
<div id="docs">
This is an example of transition effects. If the new random center is in the current extent, the map will pan smoothly. <br />
<p>This is an example of transition effects. If the new random center is in the current extent, the map will pan smoothly. <br />
The random selection will continue until you press it again. Additionally, you can single click in the map to pan smoothly
to that area, or use the pan control to pan smoothly.
</p>
</div>
<button onclick="setCenterInterval()">Start/stop random recenter</button>
<div id="map2"></div>
<div>
<p>To turn off Animated Panning, create a map with an panMethod set to
null. </p>
</div>
</body>
</html>

View File

@@ -325,6 +325,14 @@ OpenLayers.Map = OpenLayers.Class({
*/
panTween: null,
/**
* Property: panMethod
* {Function} The Easing function to be used for tweening. Default is
* OpenLayers.Easing.Expo.easeOut. Setting this to 'null' turns off
* animated panning.
*/
panMethod: OpenLayers.Easing.Expo.easeOut,
/**
* Constructor: OpenLayers.Map
* Constructor for a new OpenLayers.Map instance.
@@ -1317,9 +1325,9 @@ OpenLayers.Map = OpenLayers.Class({
* lonlat - {<OpenLayers.Lonlat>}
*/
panTo: function(lonlat) {
if (this.getExtent().containsLonLat(lonlat)) {
if (this.panMethod && this.getExtent().containsLonLat(lonlat)) {
if (!this.panTween) {
this.panTween = new OpenLayers.Tween(OpenLayers.Easing.Expo.easeOut);
this.panTween = new OpenLayers.Tween(this.panMethod);
}
var center = this.getCenter();
var from = {