可以平移/缩放功能在Android图形页面被禁止,同时允许用户点击一个ItemizedOverlay? [英] Can panning/zooming be disabled in an android MapView while allowing users to click on an ItemizedOverlay?
问题描述
有没有禁用平移/缩放,并保持地图叠加可点击的方式?
Is there a way of disabling panning/zooming and keeping map overlays clickable?
我特别想,我想在周围地图的视口移动用户拒绝被tappable一个ItemizedOverlay(这是一个为游戏)。
I am specifically thinking about an ItemizedOverlay that I want to be tappable while denying users from moving around the map's viewport (It's for a game).
我见过同样的问题回答,但答案可悲的是不允许被点击叠加的物品。
I've seen the same question answered but the answer sadly doesn't allow for overlay items to be clicked.
非常感谢,
最好的祝福,
亚历克斯
Thanks alot, best regards, Alex
推荐答案
我知道这个问题是有点老了,但我有同样的问题,并找到了解决办法,这不是一个优雅的解决方案,但似乎工作。
I know this question is a little old but I had the same problem and found a workaround, it's not a graceful solution but appears to work.
首先,你必须创建自己的地图子类中重写onTouchEvent处理程序
First you have to create your own map subclass overriding the onTouchEvent handler
public class NonPannableMapView extends MapView {
public NonPannableMapView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public NonPannableMapView(Context context, AttributeSet attrs){
super(context, attrs);
}
public NonPannableMapView(Context context, String apiKey) {
super(context, apiKey);
}
@Override
public boolean onTouchEvent(MotionEvent ev) {
//Handle a move so there is no panning or zoom
if(ev.getAction() == MotionEvent.ACTION_MOVE)
return true;
return super.onTouchEvent(ev);
}
}
然后,它只是改变以NonPannableMapView在布局的MapView参考的情况。
Then it's just a case of changing the MapView reference in your layout to NonPannableMapView.
这篇关于可以平移/缩放功能在Android图形页面被禁止,同时允许用户点击一个ItemizedOverlay?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!