我有一个应用程序使用mapview-overlay-manager代码在Web API上使用LazyLoadManager绘制地图标记。当我拖动地图时,标记会按预期加载/卸载。Popup Balloons在MapView上点击OverlayItem后随机消失
在标记的水龙头上,我膨胀balloon.xml文件并使用它在标记上方显示气球。这是问题所在。它可以工作,但突然间(我不能一直重复)气球覆盖将停止显示在屏幕上。
这很奇怪,因为标记仍然表明它已被挖掘,但随后气球停止显示。我检查过气球不是空(它不是),并且itemInfo不是null。在调用.addView(...)后,它只是没有添加到MapView中,但所有的参数都是有效的。
备注:任何时候发生这种情况时,所有叠加层都变为真正的黑色,并且叠加阴影从半透明变为黑色。我不知道是什么原因造成的,但它发生在同一时间,这使我相信它是一个绘图问题。
上述问题的代码如下。任何提示/想法/等将不胜感激。
@Override
public boolean onSingleTap(MotionEvent e, ManagedOverlay overlay, GeoPoint point, ManagedOverlayItem item) {
if(mBalloon != null)
{
mMapView.removeView(mBalloon);
mBalloon = null;
}
if(item != null) {
//Toast.makeText(getApplicationContext(), item.getTitle(), Toast.LENGTH_SHORT).show();
MapView.LayoutParams balloonLayoutParams = new MapView.LayoutParams(350, MapView.LayoutParams.WRAP_CONTENT, item.getItemInfo().getMarkerPoint(mMapView.getProjection()), MapView.LayoutParams.BOTTOM_CENTER);
if(mBalloon == null) {
if(mLayoutInflater == null) {
mLayoutInflater = getLayoutInflater();
}
ViewGroup parent = (ViewGroup)mMapView.getParent();
mBalloon = (BalloonLayout) mLayoutInflater.inflate(R.layout.balloon_layout, parent, false);
}
TextView title = (TextView)mBalloon.findViewById(R.id.title);
title.setText(item.getItemInfo().getTitle());
TextView subTitle = (TextView)mBalloon.findViewById(R.id.subTitle);
subTitle.setText(item.getItemInfo().getBalloonSubTitle());
if(DEBUG) Log.d(TAG, "Setting on click listener.");
((ImageButton)mBalloon.findViewById(R.id.go_button)).setOnClickListener(new ViewItemInfoListener(item.getItemInfo()));
mMapView.addView(mBalloon, balloonLayoutParams);
}
return false;
}
});
// Fires off the background event to get the
overlayManager.populate();
}