80,352
社区成员
发帖
与我相关
我的任务
分享
OnTouchListener listener = new OnTouchListener() {
@Override
public boolean onTouch(View arg0, MotionEvent arg1) {
/**
* Projection 用于将屏幕坐标转换为地理位置坐标
*/
int x = (int) arg1.getX();
int y = (int) arg1.getY();
currentPt = mMapView.getProjection().fromPixels(x, y);
updateMapState(arg1);
/**
* 传递点击事件给MapView,sdk会自己处理缩放,平移等手势操作
*/
return false;
}
};
mMapView.setOnTouchListener(listener);
private class GISGestureListener extends SimpleOnGestureListener {
private Context mContext;
GISGestureListener(Context context) {
mContext = context;
}
/**
* 用户(轻触触摸屏后)松开,由一个1个MotionEvent ACTION_UP触发
*/
@Override
public boolean onSingleTapUp(MotionEvent e) {
Toast.makeText(mContext, "SHOW " + e.getX()+" "+e.getY(), Toast.LENGTH_SHORT).show(); ;
int x = (int) e.getX();
int y = (int) e.getY();
currentPt = mMapView.getProjection().fromPixels(x, y);
pop.hidePop();
popupText.setBackgroundResource(R.drawable.popup);
popupText.setText("点击选择该点为资源坐标");
pop.showPopup(BMapUtil.getBitmapFromView(popupText), currentPt, 8);
return false;
}
}
。。。。
mGestureDetector = new GestureDetector(this, new GISGestureListener(this));
OnTouchListener listener = new OnTouchListener() {
@Override
public boolean onTouch(View arg0, MotionEvent arg1) {
/**
* Projection 用于将屏幕坐标转换为地理位置坐标
*/
//updateMapState(arg1);
/**
* 传递点击事件给MapView,sdk会自己处理缩放,平移等手势操作
*/
return mGestureDetector.onTouchEvent(arg1) ;
}
};