I've got two points on a google map and I want to transition between them using a smooth animation. Using the map.panTo() method I can pan to them but the animation only works if the second point is开发者_JAVA百科 less than the width/height of the map.
So the idea i've come up with is to break the transition up into something like:
var destination = next point
get center
check if the destination is in bounds
if so
panTo it
else
get the midpoint between center and point
if midpoint in bounds pan
else get midpoint etc....
So here the travelling is broken up into as little steps as possible. Problem is, i cant get my head around how to implement this in code(the recursive midpoint checking that is) Any help would be great.
the page im having this problem with is http://amishh4cker.com/geocaching.html
if ( end - start ) > width and ( end - start ) < maxpandistance then midpoint = start + ( end - start ) * .5 while midpoint is not on screen midpoint = start + ( midpoint - start ) * .5 loop panto midpoint else panto end
Something like that, although I could see rather large distances causing slowdowns, especially as the window becomes smaller.
精彩评论