缩放和动画指向Android的MapView类 [英] Zooming and animating to point mapview android

查看:111
本文介绍了缩放和动画指向Android的MapView类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此​​,在我目前的应用程序,我想使变焦纬度/长点,而且还使用animateTo(或同等学历),以确保屏幕正确居中。目前,我只是在做这样的事情:

So in my current application, I want to zoom to a lat/long point, but also use the animateTo (or equivalent) to make sure the screen is properly centered. Currently I'm just doing something like this:

_mapController.animateTo(new GeoPoint(googleLat, googleLng));


            // Smooth zoom handler
            int zoomLevel = _mapView.getZoomLevel();
            int targetZoomLevel = AppConstants.MAP_ZOOM_LEVEL_SWITCH;
            long delay = 0;
            while (zoomLevel++ < targetZoomLevel) {
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                       _mapController.zoomIn();
                    }
                }, delay);

                delay += 350; // Change this to whatever is good on the device
            }

这类型的作品,但发生的事情是,我的线程开始之前,动画为完成,所以它放大,然后跳跃,以显示正确中心的GeoPoint。有没有在同一时间顺利深入到一定的缩放级别,以及移动到一个GeoPoint对象的方法吗?官方GOOGL eMaps应用程序如何放大到你搜索后一个地址类似就是我希望做的。

This kind of works, but what happens is that my thread starts, BEFORE the 'animate to' finishes, so it zooms in and then 'jumps' to display the correct center geoPoint. Is there a way to smoothly 'drill down' to a certain zoom level, as well as move to a geoPoint at the same time? Similar to how the official Googl eMaps application zooms to an address after you've searched for it is what I'm looking to do.

推荐答案

我会做这样的事情:

_mapController.animateTo(new GeoPoint(googleLat,googleLong), new Runnable() {
 public void run()
 {
  _mapController.zoomIn ();
 }
});

这将实现泛当时的变焦效果。你可以试试你的逻辑同样可运行内部执行多步zoomIn的。

This will achieve a pan-then-zoom effect. You can try your same logic inside the runnable to perform multi-step zoomIn's.

这篇关于缩放和动画指向Android的MapView类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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