Issue
I use my MapView (new API v2) with a list of points that belong to a route. They are pretty close together. My problem is, if I do the animation steps calling
mMapInstance.animateCamera(CameraUpdateFactory.newLatLng(mNextPosition),ms, null);
The cameraman behaves like an intrepid grasshopper, and pans out and in exaggerately, and in the process al the slide cache gets @##@#@#!
What is the best approach to animate a path and get a uniform scrolling experience? Speed is not a problem, I would use low speed, I am interested in the smoothness...
I'll be more than happy if I could simulate a path I do with the finger.. because the map behaves beautifully and has a lot of tiles around cached. But any attempt to programmatically move the map results in the bold animation, white screen, reloading of tiles ...
Thanks in advance !!!
Solution
Well, I hope somebody provide a better answer, but with the many experiments I've done, I was unable to get a decent smooth scroll using animateCamera.
Regardless of only changing Lat/Lng for points close together, the cameraman kept making impressive takeoffs and landings.
I have had limited 'el-cheapo' animation success with the following routine:
private void animateTo(double lat, double lon, double zoom, double bearing, double tilt, final int milliseconds) {
if (mMapInstance==null) return;
mMapInstance.setMapType(paramMapMode);
mCurrentPosition=new LatLng(lat,lon);
// animate camera jumps too much
// so we set the camera instantly to the next point
mMapInstance.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition(mCurrentPosition,(float)zoom, (float)tilt, (float)bearing)));
// give Android a break so it can load tiles. If I start the animation
// without pause, no tile loading is done
mMap.postDelayed(new Runnable(){
@Override
public void run() {
// keeping numbers small you get a nice scrolling effect
mMapInstance.animateCamera(CameraUpdateFactory.scrollBy(250-(float)Math.random()*500-250, 250-(float)Math.random()*500),milliseconds,null);
}},500);
}
This routine, called with milliseconds value in the 10000s, goes to one point then makes a flyover animation in a random direction keeping the damn zoom tranquilo. As the pixel values are very small, chances are it's everything cached.
Anybody with a better solution? Is it reasonable or possible to try to inject touch events to simulate a 'touched' fling?
Answered By - rupps
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.