在谷歌地图V2动画信息窗口 [英] Animated infowindow in Google Maps v2

查看:155
本文介绍了在谷歌地图V2动画信息窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我询问有关申请的动画标记弹出窗口(信息窗口),并解释了为什么这是不可能的:

  

注意:所得出的信息窗口是不是一个实时视图。视图是在它返回时呈现为图像(使用 View.draw(画布))。这意味着,任何后续更改视图不会由地图上的信息窗口被反射。以后要更新的信息窗口(如后的图像加载),调用 showInfoWindow()。此外,信息窗口将不会尊重任何互动的典型的一个普通视图,如触摸或手势事件。但是,您可以收听到整个信息窗口上通用的单击事件,如下面的部分所述。

研究更多一些,我发现用V1是手动创建的标记位置查看一个项目。要做到这一点,其他人做了这样的事情:

 公共无效showPopup(查看视图,GeoPoint对象来看,布尔centerPopup){

    removeAllViews();

    MapView.LayoutParams LP =新MapView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT,
            点,
            Utils.dipsToPixels(0.0,mContext)
            Utils.dipsToPixels(-12.0f,mContext)
            MapView.LayoutParams.BOTTOM_CENTER);

    如果(centerPopup){
        。getController()animateTo(点);
        mIgnoreNextChangeEvent = TRUE;
    }

    查看气囊= mInflater.inflate(R.layout.balloon,NULL);
    balloon.setLayoutParams(LP);

    ((ViewGroup中)balloon.findViewById(R.id.balloonBody))addView(图)。

    balloon.startAnimation(AnimationUtils.loadAnimation(mContext,R.anim.bounce_in));
    addView(气球);
}
 

于是,他手动创建一个气球的看法,他重视的MapView。

我一直在试图效仿使用V2同样的事情,但我一直没能和我甚至不知道这是可能的。比如,我用GoogleMap的,而不是图形页面,我不知道这有什么用一些V1和V2之间的差异。

我要补充什么我到目前为止只是作为一个参考。我试图从其他项目复制code,并试图修改它,它会在这一个,但我一直没能即使编译。

 公共布尔onMarkerClick(标记标记){
    map.removeAllViews();

    MapView.LayoutParams LP =新MapView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT,
            marker.getPosition(),
            Tools.dipsToPixels(0.0,这一点),
            Tools.dipsToPixels(-12.0f,这一点),
            MapView.LayoutParams.BOTTOM_CENTER);

    如果(centerPopup){
        。getController()animateTo(点);
        mIgnoreNextChangeEvent = TRUE;
    }

    查看气囊= mInflater.inflate(R.layout.balloon,NULL);
    balloon.setLayoutParams(LP);

    ((ViewGroup中)balloon.findViewById(R.id.balloonBody))addView(图)。

    balloon.startAnimation(AnimationUtils.loadAnimation(mContext,R.anim.bounce_in));
    addView(气球);

    返回false;
}
 

解决方案

您不能同步滚动任何查看地图可能超过它,即使你完成了这样的解决方案,它看起来laggy。

你试过这种解决方法: http://stackoverflow.com/a/16147630/2183804

I recently asked about applying an animation to a marker popup window (infowindow) and was explained why that wasn't possible:

Note: The info window that is drawn is not a live view. The view is rendered as an image (using View.draw(Canvas)) at the time it is returned. This means that any subsequent changes to the view will not be reflected by the info window on the map. To update the info window later (e.g., after an image has loaded), call showInfoWindow(). Furthermore, the info window will not respect any of the interactivity typical for a normal view such as touch or gesture events. However you can listen to a generic click event on the whole info window as described in the section below.

Researching some more, I found a project using V1 that manually creates the View on the marker's position. To do this, the other guy did something like this:

public void showPopup(View view, GeoPoint point, boolean centerPopup) {

    removeAllViews();

    MapView.LayoutParams lp = new MapView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT,
            point,
            Utils.dipsToPixels(0.0f, mContext),
            Utils.dipsToPixels(-12.0f, mContext),
            MapView.LayoutParams.BOTTOM_CENTER);

    if (centerPopup) {
        getController().animateTo(point);
        mIgnoreNextChangeEvent = true;
    }

    View balloon = mInflater.inflate(R.layout.balloon, null);
    balloon.setLayoutParams(lp);

    ((ViewGroup) balloon.findViewById(R.id.balloonBody)).addView(view);

    balloon.startAnimation(AnimationUtils.loadAnimation(mContext, R.anim.bounce_in));
    addView(balloon);
}

So he manually creates a balloon view and attaches it to the MapView.

I've been trying to emulate this same thing using V2 but I haven't been able and I don't even know if this is possible at all. For example, I use "GoogleMap" instead of "MapView" and I'm not sure if this has anything to do with some of the differences between V1 and V2.

I'm going to add what I have so far just as a reference. I tried to replicate the code from the other project and try to modify it so it will work in this one but I haven't been able to even compile it.

public boolean onMarkerClick(Marker marker) {
    map.removeAllViews();

    MapView.LayoutParams lp = new MapView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT,
            marker.getPosition(),
            Tools.dipsToPixels(0.0f, this),
            Tools.dipsToPixels(-12.0f, this),
            MapView.LayoutParams.BOTTOM_CENTER);

    if (centerPopup) {
        getController().animateTo(point);
        mIgnoreNextChangeEvent = true;
    }

    View balloon = mInflater.inflate(R.layout.balloon, null);
    balloon.setLayoutParams(lp);

    ((ViewGroup) balloon.findViewById(R.id.balloonBody)).addView(view);

    balloon.startAnimation(AnimationUtils.loadAnimation(mContext, R.anim.bounce_in));
    addView(balloon);

    return false;
}

解决方案

You cannot synchronize scrolling map with any view that could be over it and even if you completed this kind of solution it would look laggy.

Have you tried this workaround: http://stackoverflow.com/a/16147630/2183804 ?

这篇关于在谷歌地图V2动画信息窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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