从屏幕上方慢慢降标记位置上的Andr​​oid地图V2 [英] Drop marker slowly from top of screen to location on android map V2

查看:202
本文介绍了从屏幕上方慢慢降标记位置上的Andr​​oid地图V2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Android地图v2works罚款,我可以添加和删除标记onLong触摸的位置。

I am using android maps v2works fine I can add and remove markers onLong Touch on locations.

问题: 我想慢慢降标记为触摸位置即我希望用户看到的屏幕上方的地步,它被丢弃(触摸位置)标记浮动。

Problem: I would like to drop the marker slowly into the touched location i.e. I want the user to see the marker floating from the top of the screen to the point where it is dropped(touched location).

目前,标记只出现在触摸位置,这样你必须抬起你的手指一看就知道它已被删除。这将是很好看到它从屏幕顶部的到来。

Currently; the marker just appears on the touched location such that you have to lift you finger to see that it has been dropped. It would be nice to see it coming from the top of the screen.

感谢。

推荐答案

您可以用code与此类似做到这一点(未经测试):

You can achieve this with a code similar to this (untested):

final LatLng target = ...;

final long duration = 400;
final Handler handler = new Handler();
final long start = SystemClock.uptimeMillis();
Projection proj = map.getProjection();

Point startPoint = proj.toScreenLocation(target);
startPoint.y = 0;
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
        }
    }
});

这篇关于从屏幕上方慢慢降标记位置上的Andr​​oid地图V2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆