Android google maps v2中的标记动画
我正在使用数据库中的坐标逐个向mapView添加标记。我需要同时设置所有标记的动画 在循环中,向每个添加的标记添加动画,但仅对最后添加的标记有效Android google maps v2中的标记动画,android,google-maps-android-api-2,Android,Google Maps Android Api 2,我正在使用数据库中的坐标逐个向mapView添加标记。我需要同时设置所有标记的动画 在循环中,向每个添加的标记添加动画,但仅对最后添加的标记有效 **code for adding markers to map is:** Marker marker; do { marker= mapView.addMarker(new MarkerOptions()
**code for adding markers to map is:**
Marker marker;
do
{
marker= mapView.addMarker(new MarkerOptions()
.position(new LatLng(latitude, longitude))
.icon(BitmapDescriptorFactory
.fromBitmap((bitmap)))
.snippet(text + " ")
.title(mine_name));
//handling animation
applyed Bounce Interpolator
final Handler handler = new Handler();
final long start = SystemClock.uptimeMillis();
Projection proj =mapView.getProjection();
Point startPoint =proj.toScreenLocation(new LatLng( latitude,longitude));
startPoint.offset(0, -100);
final LatLng startLatLng = proj .fromScreenLocation(startPoint);
final long duration = 1500;
final Interpolator interpolator = new BounceInterpolator();
handler.post(new Runnable() {
@Override public void run() {
long elapsed =SystemClock.uptimeMillis() - start;
float t =interpolator .getInterpolation((float) elapsed /
duration);
double lng = t * new LatLng(latitude,longitude).longitude + (1 - t) *
startLatLng.longitude;
double lat = t * new LatLng(latitude, longitude).latitude + (1 - t) *
startLatLng.latitude;
marker.setPosition(new LatLng(lat, lng));
if (t < 1.0) {
// Post again 16ms later.
handler.postDelayed(this, 32); } } });
}while(count>0)
**向地图添加标记的代码为:**
标记;
做
{
marker=mapView.addMarker(新的MarkerOptions()
.位置(新车床(纬度、经度))
.图标(位图描述符工厂)
.fromBitmap((位图)))
.代码段(文本+“”)
.头衔(矿名);
//处理动画
应用反弹插值器
最终处理程序=新处理程序();
最终长启动=SystemClock.uptimeMillis();
Projection proj=mapView.getProjection();
点起始点=项目至屏幕位置(新纬度、经度);
起始点偏移量(0,-100);
最终LatLng StartAtlng=屏幕位置(起始点)的项目;
最终长持续时间=1500;
最终插值器插值器=新的反弹插值器();
handler.post(新的Runnable(){
@重写公共void run(){
长时间运行=SystemClock.uptimeMillis()-开始;
float t=interpolator.getInterpolation((float)经过/
持续时间);
双lng=t*新LatLng(纬度、经度)。经度+(1-t)*
经度;
双纬度=t*新纬度(纬度、经度)。纬度+(1-t)*
纬度;
标记器设置位置(新板条(板条,板条));
如果(t<1.0){
//16毫秒后再次发布。
postDelayed(this,32);}});
}而(计数>0)
但它正在为最后添加的pin工作。
我需要同时为所有管脚制作动画(即同时将动画反射到管脚)
提前感谢。动画Anukool怎么样?所有标记都需要不同的动画吗?是的,我需要不同的动画(除了给定的动画之外)意味着在添加到地图时一次对所有标记显示相同的动画大多数场景一次对标记显示动画。