我有一个应用程序使用
mapview-overlay-manager
使用web api中的LazyLoadManager在地图视图上绘制地图标记的代码。当我拖动地图时,标记按预期加载/卸载。
气球.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();
}