-
Problem in Google map rotation in Android
about 8 years ago
-
about 8 years ago
Hi amit ,
What actual animation do you want to implement ? Like translate animation when the position get displaced or something else?
-
-
about 8 years ago
Hi devesh, thanks for the help. But the code that you have mentioned is for moving the car and I think the problem is with the rotation animation code. If we are not including the same (the rotation code) the car is moving smoothly but the turns that car is taking are not smooth for the same we have introduced the rotation code. After applying the same the car is revolving 360 degree sometime like 2 or 3 times in a trip. I have to stop the same "the car revolving" I am not getting the reason why it is behaving so and it is happening occasionally not every time. Like after travelling some distance randomly it revolve at any point 1 or 2 time and then it moves smoothly. The car animation of 360 degree that is happening occasionally I have to stop that.
-
-
about 8 years ago
I have implemented the same piece of code and it worked liked a charm.
private void animateMarker(LatLng latlng,final Marker marker){ final LatLng target = latlng; final long duration = 800; final Handler handler = new Handler(); final long start = SystemClock.uptimeMillis(); Projection proj = mMap.getProjection(); Point startPoint = proj.toScreenLocation(marker.getPosition()); final LatLng startLatLng = proj.fromScreenLocation(startPoint); final Interpolator interpolator = new LinearInterpolator(); handler.post(new Runnable() { @Override public void run() { long elapsed = SystemClock.uptimeMillis() - start; float t = interpolator.getInterpolation((float) elapsed / duration); double lng = t * target.longitude + (1 - t) * startLatLng.longitude; double lat = t * target.latitude + (1 - t) * startLatLng.latitude; marker.setPosition(new LatLng(lat, lng)); if (t < 1.0) { // Post again 10ms later. handler.postDelayed(this, 10); } else { // animation ended } } }); }
-
-
about 8 years ago
Hi Devesh, yes I want to implement the translate animation. The only thing that I am missing out is sometime the car is moving at 360 degree clockwise and anticlockwise as well on map and I am not getting the reason of behavior of the same Apart from that car is moving smoothly .
-
4 Answer(s)