移动标记在谷歌地图V2的android标记、地图、android

由网友(安颜)分享简介:我做图的聚类在Android的谷歌地图V2。我只是想标记动画从一个GeoPoint对象到另一个。有没有一种方法来移动标记在谷歌地图V2?I am doing map clustering in Android Google maps v2.I just want to animate the marker fro...

我做图的聚类在Android的谷歌地图V2。 我只是想标记动画从一个GeoPoint对象到另一个。有没有一种方法来移动标记在谷歌地图V2?

I am doing map clustering in Android Google maps v2. I just want to animate the marker from one geopoint to another. Is there a way to move a marker in Google maps v2?

推荐答案

有移动的标志在谷歌地图V2演示程序..玩库的样品中的一个例子!

There's one example of moving marker in google map v2 demo app .. in the sample of the play library!!

我已经研究过了!这里code移动的标记: - >

I have looked into that!! here the code for moving an marker : -- >

    public void animateMarker(final Marker marker, final LatLng toPosition,
            final boolean hideMarker) {
        final Handler handler = new Handler();
        final long start = SystemClock.uptimeMillis();
        Projection proj = mGoogleMapObject.getProjection();
        Point startPoint = proj.toScreenLocation(marker.getPosition());
        final LatLng startLatLng = proj.fromScreenLocation(startPoint);
        final long duration = 500;

        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 * toPosition.longitude + (1 - t)
                        * startLatLng.longitude;
                double lat = t * toPosition.latitude + (1 - t)
                        * startLatLng.latitude;
                marker.setPosition(new LatLng(lat, lng));

                if (t < 1.0) {
                    // Post again 16ms later.
                    handler.postDelayed(this, 16);
                } else {
                    if (hideMarker) {
                        marker.setVisible(false);
                    } else {
                        marker.setVisible(true);
                    }
                }
            }
        });
    }

希望它可以帮助每一个人!

Hope it help every one!!

阅读全文

相关推荐

最新文章