| 712 | | // adjust |
|---|
| 713 | | var newCenterPx = centerPx.add(dx, dy); |
|---|
| 714 | | |
|---|
| 715 | | // only call setCenter if there has been a change |
|---|
| 716 | | if (!newCenterPx.equals(centerPx)) { |
|---|
| 717 | | var newCenterLonLat = this.getLonLatFromViewPortPx(newCenterPx); |
|---|
| 718 | | this.setCenter(newCenterLonLat); |
|---|
| | 739 | if (animated) { |
|---|
| | 740 | this.panSlide(dx, dy, |
|---|
| | 741 | this.slideSteps, |
|---|
| | 742 | this.slideWait, |
|---|
| | 743 | this.slidePower); |
|---|
| | 744 | } else { |
|---|
| | 745 | |
|---|
| | 746 | // getCenter |
|---|
| | 747 | var centerPx = this.getViewPortPxFromLonLat(this.getCenter()); |
|---|
| | 748 | |
|---|
| | 749 | // adjust |
|---|
| | 750 | var newCenterPx = centerPx.add(dx, dy); |
|---|
| | 751 | |
|---|
| | 752 | // only call setCenter if there has been a change |
|---|
| | 753 | if (!newCenterPx.equals(centerPx)) { |
|---|
| | 754 | var newCenterLonLat = this.getLonLatFromViewPortPx(newCenterPx); |
|---|
| | 755 | this.setCenter(newCenterLonLat, null, null, this.animated); |
|---|
| | 756 | } |
|---|
| | 867 | /** Position changer with Memory by www.hesido.com |
|---|
| | 868 | * modified by dncpax for OpenLayers |
|---|
| | 869 | * |
|---|
| | 870 | * @param {int} slideX |
|---|
| | 871 | * @param {int} slideY |
|---|
| | 872 | * @param {int} totalSteps |
|---|
| | 873 | * @param {int} intervals |
|---|
| | 874 | * @param {float} power |
|---|
| | 875 | */ |
|---|
| | 876 | panSlide: function( slideX, slideY, totalSteps, interval, power) { |
|---|
| | 877 | if (this.animatedPanningIntervalID) { |
|---|
| | 878 | window.clearInterval(this.animatedPanningIntervalID); |
|---|
| | 879 | this.animatedPanningIntervalID = null; |
|---|
| | 880 | } |
|---|
| | 881 | var context = { |
|---|
| | 882 | 'map': this, |
|---|
| | 883 | 'slideX': slideX, |
|---|
| | 884 | 'slideY': slideY, |
|---|
| | 885 | 'totalSteps': totalSteps, |
|---|
| | 886 | 'step': 0, |
|---|
| | 887 | 'power': power |
|---|
| | 888 | }; |
|---|
| | 889 | var move = function() { |
|---|
| | 890 | var dx = OpenLayers.Util.easeInOut(this.slideX, |
|---|
| | 891 | this.totalSteps, |
|---|
| | 892 | this.step, |
|---|
| | 893 | this.power); |
|---|
| | 894 | var dy = OpenLayers.Util.easeInOut(this.slideY, |
|---|
| | 895 | this.totalSteps, |
|---|
| | 896 | this.step, |
|---|
| | 897 | this.power); |
|---|
| | 898 | this.map.pan(dx, dy, false); |
|---|
| | 899 | this.step++; |
|---|
| | 900 | if (this.step > this.totalSteps) { |
|---|
| | 901 | window.clearInterval(this.map.animatedPanningIntervalID); |
|---|
| | 902 | this.map.animatedPanningIntervalID = null; |
|---|
| | 903 | } |
|---|
| | 904 | }; |
|---|
| | 905 | |
|---|
| | 906 | this.animatedPanningIntervalID = |
|---|
| | 907 | window.setInterval(move.bindAsEventListener(context), |
|---|
| | 908 | interval); |
|---|
| | 909 | }, |
|---|
| | 910 | |
|---|
| | 911 | |
|---|