나는이 일 동안 내 머리를 꽉 쥐고 있었고 Google 검색 결과를 가지고 있지만보고 한 다른 사용자를 찾을 수없는 것 같습니다. 그러한 문제 (그것을 놓쳤을 수도 있음).Longpress의 Android Map Marker가 실제로 LongPressed 지역 아래에 표시됨 (API 15)
필자는 길쭉한 소리를 듣고 맵에서 마커를 그릴 때 사용하는 Mapview 클래스를 사용자 정의했습니다. API-8에서는 괜찮은 부분입니다. 그러나 API-15에서 마커는 사용자 손가락이 롱 프레스를 할 때 약 2cm 아래로 오프셋됩니다. 이것은 실제 디바이스 (samsung s2)와 Eclipse 에뮬레이터에서 모두 관찰됩니다. 또한 마커 영역 대 길게 눌러 진 손가락 영역 (약 2cm 오프셋)이 모든 줌 레벨에서 관찰됩니다.
여기 (어딘가에서 그것을 꼴) 내 맞춤지도보기 클래스입니다 :
public class MyCustomMapView extends MapView {
public interface OnLongpressListener {
public void onLongpress(MapView view, GeoPoint longpressLocation);
}
static final int LONGPRESS_THRESHOLD = 500;
private GeoPoint lastMapCenter;
private Timer longpressTimer = new Timer();
private MyCustomMapView.OnLongpressListener longpressListener;
public MyCustomMapView(Context context, String apiKey) {
super(context, apiKey);
}
public MyCustomMapView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public MyCustomMapView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public void setOnLongpressListener(MyCustomMapView.OnLongpressListener listener) {
longpressListener = listener;
}
@Override
public boolean onTouchEvent(MotionEvent event) {
handleLongpress(event);
return super.onTouchEvent(event);
}
private void handleLongpress(final MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
// Finger has touched screen.
longpressTimer = new Timer();
longpressTimer.schedule(new TimerTask() {
@Override
public void run() {
GeoPoint longpressLocation = getProjection().fromPixels((int)event.getX(), (int)event.getY());
/*
* Fire the listener. We pass the map location
* of the longpress as well, in case it is needed
* by the caller.
*/
longpressListener.onLongpress(MyCustomMapView.this, longpressLocation);
}
}, LONGPRESS_THRESHOLD);
lastMapCenter = getMapCenter();
}
if (event.getAction() == MotionEvent.ACTION_MOVE) {
if (!getMapCenter().equals(lastMapCenter)) {
// User is panning the map, this is no longpress
longpressTimer.cancel();
}
lastMapCenter = getMapCenter();
}
if (event.getAction() == MotionEvent.ACTION_UP) {
// User has removed finger from map.
longpressTimer.cancel();
}
if (event.getPointerCount() > 1) {
// This is a multitouch event, probably zooming.
longpressTimer.cancel();
}
}
그리고 이것은 내가 위의 클래스를 호출하는 방법이다 : 그것은 setBounds 문제처럼 보인다
custom_marker = getResources().getDrawable(R.drawable.marker3);
custom_marker.setBounds(-custom_marker.getIntrinsicWidth(), -custom_marker.getIntrinsicHeight(), 0, 0);
customSitesOverlay = new CustomSitesOverlay(custom_marker);
mapView.getOverlays().add(customSitesOverlay);
customSitesOverlay.addOverlay(new OverlayItem(longpressLocation, "User Marker", id));
나도 같은 문제에 직면 해있다. @ 마카, 솔루션을 찾은 다음 공유 해주세요 .... 미리 감사드립니다. –
죄송합니다 @MukeshY 우리는이 문제를 모두 포기하고 코드를 통해지도에 고정 핀을 선택했습니다. –