use of com.amap.api.maps.Projection in project ride-read-android by Ride-Read.
the class MapFragment method addSignInMarker.
private void addSignInMarker(LatLng latLng) {
final Marker marker = addMarker(latLng);
if (marker != null) {
final long start = SystemClock.uptimeMillis();
Projection proj = mAMap.getProjection();
Point markerPoint = proj.toScreenLocation(latLng);
markerPoint.offset(0, -500);
final LatLng startLatLng = proj.fromScreenLocation(markerPoint);
final long duration = 2000;
final Interpolator interpolator = new BounceInterpolator();
mHandler.post(new Runnable() {
@Override
public void run() {
long elapsed = SystemClock.uptimeMillis() - start;
float t = interpolator.getInterpolation((float) elapsed / duration);
double lng = t * latLng.longitude + (1 - t) * startLatLng.longitude;
double lat = t * latLng.latitude + (1 - t) * startLatLng.latitude;
marker.setPosition(new LatLng(lat, lng));
if (t < 1.0) {
mHandler.postDelayed(this, 16);
}
}
});
}
mHandler.postDelayed(() -> {
mSignInDialogFragment = SignInDialogFragment.newInstance(AMapLocationUtils.getLocDetail());
mSignInDialogFragment.show(getFragmentManager(), "sign_in");
}, 1000L);
}
Aggregations