我有一个应用程序,使用mapview-overlay-manager代码在MapView上绘制地图标记,并使用来自Web API的LazyLoadManager。当我拖动地图时,标记会按预期加载/取消加载。
当我点击标记时,我会填充一个balloon.xml文件,并使用它在标记上方显示气球。这就是问题所在。它能够正常工作,但突然间(我无法重复)气球覆盖层将停止在屏幕上显示。
虽然很奇怪,但标记仍然显示已被点击,但气球却不再显示。我已经检查过气球不为空(它确实不为空),并且itemInfo也不为空。调用.addview(...)后,它只是没有被添加到MapView中,但所有参数都是有效的。
另外:每当发生这种情况时,所有叠加层都会变得非常暗淡,叠加层阴影从半透明变成黑色。我不知道是什么原因导致的,但它同时发生,这使我相信它是一个绘制问题。
以下是上述问题的代码。如有任何提示/想法等,将不胜感激。
当我点击标记时,我会填充一个balloon.xml文件,并使用它在标记上方显示气球。这就是问题所在。它能够正常工作,但突然间(我无法重复)气球覆盖层将停止在屏幕上显示。
虽然很奇怪,但标记仍然显示已被点击,但气球却不再显示。我已经检查过气球不为空(它确实不为空),并且itemInfo也不为空。调用.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();
}