Skip to content

Commit

Permalink
add speed and zoomFactor args to zoomPanTo, update API
Browse files Browse the repository at this point in the history
  • Loading branch information
mourner committed Feb 12, 2014
1 parent da42a4a commit 983ae5e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
10 changes: 6 additions & 4 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ Options that define the initial position of the map unless `hash` is set to true
#### Methods

- **setPosition**_(zoom, lat, lon, angle)_ - set map position (zoom, center, rotation)
- **zoomTo**_(zoom, duration)_ - zoom to a certain zoom level with easing
- **scaleTo**_(scale, duration)_ - zoom by a certain scale with easing
- **panTo**_(lat, lon, duration)_ - pan to a certain location level with easing
- **panBy**_(x, y, duration)_ - pan by a certain number of pixels with easing
- **zoomTo**_(zoom, duration?)_ - zoom to a certain zoom level with easing (duration in ms, 500 by default)
- **scaleTo**_(scale, duration?)_ - zoom by a certain scale with easing
- **panTo**_(lat, lon, duration?)_ - pan to a certain location level with easing
- **zoomPanTo**_(lat, lon, zoom?, speed?, zoomFactor?)_ - zoom-pan optimal path easing to a specified location,
optionally passing animation speed (1.2 by default) and zoomFactor (1.42 by default, bigger value means more pronounced zoom out)
- **panBy**_(x, y, duration?)_ - pan by a certain number of pixels with easing
- **stop**_() - stop current animation
- **resize**_()_ - detect the map's new width and height and resize it
- **setAngle**_(center, angle)_ - sets map rotation angle in radians (doesn't care for center)
Expand Down
7 changes: 4 additions & 3 deletions js/ui/easings.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ util.extend(exports, {
map.setAngle(center, 0);
},

zoomPanTo: function(lat, lon, zoom) {
zoomPanTo: function(lat, lon, zoom, V, rho) {
var tr = this.transform,
fromX = tr.lonX(tr.lon),
fromY = tr.latY(tr.lat),
Expand All @@ -110,11 +110,12 @@ util.extend(exports, {
startWorldSize = tr.worldSize;

zoom = zoom === undefined ? startZoom : zoom;
rho = rho || 1.42;
V = V || 1.2;

var w0 = Math.max(tr.width, tr.height),
w1 = w0 * tr.zoomScale(zoom - startZoom),
u1 = Math.sqrt(dx * dx + dy * dy),
rho = 1.42,
rho2 = rho * rho;

function r(i) {
Expand All @@ -132,7 +133,7 @@ util.extend(exports, {
function u(s) { return w0 * (cosh(r0) * tanh(r0 + rho * s) - sinh(r0)) / rho2; }

var S = (r(1) - r0) / rho,
duration = 1000 * S * 0.8,
duration = 1000 * S / V,
map = this;

this.stop = util.timed(function (t) {
Expand Down

0 comments on commit 983ae5e

Please sign in to comment.