gpt4 book ai didi

java - Google map v2 中的动画信息窗口

转载 作者:行者123 更新时间:2023-11-30 09:23:14 25 4
gpt4 key购买 nike

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

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.

进一步研究,我发现了一个使用 V1 的项目,该项目在标记的位置手动创建 View 。为此,另一个人做了这样的事情:

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);
}

因此他手动创建了一个气球 View 并将其附加到 MapView。

我一直在尝试使用 V2 来模拟同样的事情,但我做不到,我什至不知道这是否可行。例如,我使用“GoogleMap”而不是“MapView”,我不确定这是否与 V1 和 V2 之间的某些差异有关。

我将添加目前已有的内容,仅供引用。我试图从另一个项目复制代码并尝试修改它,以便它能在这个项目中工作,但我什至无法编译它。

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;
}

最佳答案

您无法将滚动 map 与可能覆盖它的任何 View 同步,即使您完成了这种解决方案,它也会显得滞后。

您是否尝试过此解决方法:https://stackoverflow.com/a/16147630/2183804

关于java - Google map v2 中的动画信息窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16164278/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com