public void animateCarMove1(Marker SecondMarker, LatLng beginLatLng1, LatLng endLatLng1, float duration1) { long startTime1 = SystemClock.UptimeMillis(); Android.Views.Animations.IInterpolator interpolator = new Android.Views.Animations.LinearInterpolator(); float angleDeg1 = (float)(180 * getAngle(beginLatLng1, endLatLng1) / System.Math.PI); //float angleDeg = (float)(180 * getBearing(beginLatLng, endLatLng) / System.Math.PI); Matrix matrix1 = new Matrix(); matrix1.PostRotate(angleDeg1); SecondMarker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.black1)); // marker.SetIcon(BitmapDescriptorFactory.FromBitmap(Bitmap.CreateBitmap(mMarkerIcon, 0, 0, mMarkerIcon.Width, mMarkerIcon.Height, matrix, true))); handler1 = new Handler(); action2 = () => { // your code that you want to delay here long elapsed1 = SystemClock.UptimeMillis() - startTime1; float t1 = interpolator.GetInterpolation((float)elapsed1 / duration1); // calculate new position for marker double lat1 = (endLatLng1.Latitude - beginLatLng1.Latitude) * t1 + beginLatLng1.Latitude; double lngDelta1 = endLatLng1.Longitude - beginLatLng1.Longitude; if (System.Math.Abs(lngDelta1) > 180) { lngDelta1 -= System.Math.Sign(lngDelta1) * 360; } double lng1 = lngDelta1 * t1 + beginLatLng1.Longitude; SecondMarker.Position = new LatLng(lat1, lng1); if (t1 < 1.0) { handler1.PostDelayed(action2, 1); } else { nextTurnAnimation1(); } }; handler1.Post(action2); }
public void animateCarMove(Marker marker, LatLng beginLatLng, LatLng endLatLng, float duration) { long startTime = SystemClock.UptimeMillis(); Android.Views.Animations.IInterpolator interpolator = new Android.Views.Animations.LinearInterpolator(); float angleDeg = (float)(180 * getAngle(beginLatLng, endLatLng) / System.Math.PI); Matrix matrix = new Matrix(); matrix.PostRotate(angleDeg); marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.black1)); // marker.SetIcon(BitmapDescriptorFactory.FromBitmap(Bitmap.CreateBitmap(mMarkerIcon, 0, 0, mMarkerIcon.Width, mMarkerIcon.Height, matrix, true))); handler = new Handler(); action1 = () => { long elapsed = SystemClock.UptimeMillis() - startTime; float t = interpolator.GetInterpolation((float)elapsed / duration); // calculate new position for marker double lat = (endLatLng.Latitude - beginLatLng.Latitude) * t + beginLatLng.Latitude; double lngDelta = endLatLng.Longitude - beginLatLng.Longitude; if (System.Math.Abs(lngDelta) > 180) { lngDelta -= System.Math.Sign(lngDelta) * 360; } double lng = lngDelta * t + beginLatLng.Longitude; marker.Position = new LatLng(lat, lng); if (t < 1.0) { handler.PostDelayed(action1, 13); } else { nextTurnAnimation(); } }; handler.Post(action1); }
public void animateCarTurn1(Marker marker1, float startAngle1, float endAngle1, float duration1) { Handler handler1 = new Handler(); long startTime1 = SystemClock.UptimeMillis(); Android.Views.Animations.IInterpolator interpolator1 = new Android.Views.Animations.LinearInterpolator(); float dAndgle1 = endAngle1 - startAngle1; Matrix matrix1 = new Matrix(); matrix1.PostRotate(startAngle1); Bitmap rotatedBitmap1 = Bitmap.CreateBitmap(mMarkerIcon1, 0, 0, mMarkerIcon1.Width, mMarkerIcon1.Height, matrix1, true); //marker.SetIcon(BitmapDescriptorFactory.FromBitmap(rotatedBitmap)); marker1.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.black1)); Handler h1 = new Handler(); myAction2 = () => { long elapsed1 = SystemClock.UptimeMillis() - startTime1; float t1 = interpolator1.GetInterpolation((float)elapsed1 / duration1); Matrix m1 = new Matrix(); m1.PostRotate(startAngle1 + dAndgle1 * t1); // marker.SetIcon(BitmapDescriptorFactory.FromBitmap(Bitmap.CreateBitmap(mMarkerIcon, 0, 0, mMarkerIcon.Width, mMarkerIcon.Height, m, true))); marker1.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.black1)); if (t1 < 1.0) { h1.PostDelayed(myAction2, 500); } else { nextMoveAnimation1(); } }; h1.Post(myAction2); }
public void animateCarTurn(Marker marker, float startAngle, float endAngle, float duration) { Handler handler = new Handler(); long startTime = SystemClock.UptimeMillis(); Android.Views.Animations.IInterpolator interpolator = new Android.Views.Animations.LinearInterpolator(); float dAndgle = endAngle - startAngle; Matrix matrix = new Matrix(); matrix.PostRotate(startAngle); Bitmap rotatedBitmap = Bitmap.CreateBitmap(mMarkerIcon, 0, 0, mMarkerIcon.Width, mMarkerIcon.Height, matrix, true); //marker.SetIcon(BitmapDescriptorFactory.FromBitmap(rotatedBitmap)); marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.red2)); Handler h = new Handler(); myAction1 = () => { long elapsed = SystemClock.UptimeMillis() - startTime; float t = interpolator.GetInterpolation((float)elapsed / duration); Matrix m = new Matrix(); m.PostRotate(startAngle + dAndgle * t); // marker.SetIcon(BitmapDescriptorFactory.FromBitmap(Bitmap.CreateBitmap(mMarkerIcon, 0, 0, mMarkerIcon.Width, mMarkerIcon.Height, m, true))); marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.red2)); if (t < 1.0) { h.PostDelayed(myAction1, 1000); } else { nextMoveAnimation(); } }; h.Post(myAction1); }