Search in sources :

Example 1 with Projection

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);
}
Also used : BounceInterpolator(android.view.animation.BounceInterpolator) Projection(com.amap.api.maps.Projection) BounceInterpolator(android.view.animation.BounceInterpolator) Interpolator(android.view.animation.Interpolator) Marker(com.amap.api.maps.model.Marker) LatLonPoint(com.amap.api.services.core.LatLonPoint) Point(android.graphics.Point) LatLng(com.amap.api.maps.model.LatLng)

Aggregations

Point (android.graphics.Point)1 BounceInterpolator (android.view.animation.BounceInterpolator)1 Interpolator (android.view.animation.Interpolator)1 Projection (com.amap.api.maps.Projection)1 LatLng (com.amap.api.maps.model.LatLng)1 Marker (com.amap.api.maps.model.Marker)1 LatLonPoint (com.amap.api.services.core.LatLonPoint)1