我用
+android 4.2
+osmdroid-android-3.0.9
+sherlock action bar
我需要在地图项目上显示。单击此项目显示对话框。但是onItemSingleTapUp因偏移而引发麻烦。
osmapview = (MapView) findViewById(R.id.osmapview);
osmapview.setBuiltInZoomControls(true);
osmapview.setTileSource(TileSourceFactory.MAPNIK);
osmapview.setClickable(false);
final MapController mc = osmapview.getController();
mc.setZoom(14);
ArrayList<OverlayItem> overlayItems = new ArrayList<OverlayItem>();
CustomOverLay overlays = new CustomOverLay(overlayItems, getResources().getDrawable(R.drawable.marker96));
GeoPoint p = new GeoPoint(48.427677, 35.239871);
OverlayItem overlayItem = new OverlayItem("Title1", "Description1", p);
overlays.addItem(overlayItem);
public class CustomOverLay extends ItemizedIconOverlay<OverlayItem> {
public CustomOverLay(ArrayList<OverlayItem> overlayItems, Drawable drawable) {
super(overlayItems, drawable, new OnItemGestureListener<OverlayItem>() {
@Override
public boolean onItemSingleTapUp(final int index, final OverlayItem item) {
L.e("++" + 1);
return false;
}
@Override
public boolean onItemLongPress(final int index, final OverlayItem item) {
L.e("++" + 2);
return false;
}},
new DefaultResourceProxyImpl(getApplicationContext()));
}
@Override
protected boolean onSingleTapUpHelper(int index, OverlayItem item, MapView mapView) {
L.e("+ " + item.mTitle);
return super.onSingleTapUpHelper(index, item, mapView);
}
}
地图绘制 - 确定
标记绘制 - 确定
点击标记 - 失败
如果点击标记的底部(非常底部) - 确定
偏移的原因是什么?
答案 0 :(得分:2)
关闭清单或代码中的硬件加速。有关如何执行此操作的示例,请参阅示例应用程序。 3.0.10中有更好的硬件加速支持。
答案 1 :(得分:0)