मैं इस पर अपने दिमाग को रैकिंग कर रहा हूं और इस पर गुगल और सोया है लेकिन किसी और को रिपोर्टिंग नहीं मिल रहा है ऐसी समस्या (इसे याद कर सकता था)।लॉन्गप्रेस पर एंड्रॉइड मैप मार्कर उस क्षेत्र के नीचे प्लॉट किया गया है जो वास्तविक रूप से लंबे समय तक दबाया जाता है (एपीआई 15 पर)
मेरे पास एक अनुकूलित नक्शादृश्य वर्ग है जो दूसरों के बीच लम्बाई के लिए सुनता है और मेरे मानचित्र पर मार्कर प्लॉट करने के लिए इसका उपयोग कर रहा हूं। यह एपीआई -8 पर ठीक है। लेकिन एपीआई -15 पर मार्कर को लगभग 2 सेमी नीचे ऑफसेट किया जाता है जहां उपयोगकर्ता उंगली लम्बाई कर रही है। यह वास्तविक डिवाइस (सैमसंग एस 2) और ग्रहण एमुलेटर दोनों के लिए मनाया जाता है। इसके अलावा सभी ज़ूम स्तरों पर मार्कर क्षेत्र प्लॉट (लगभग 2 सेमी तक ऑफसेट) बनाम उंगली क्षेत्र लंबे समय से दबाया जाता है।
यहाँ मेरी अनुकूलित MapView क्लास (कहीं से यह yanked) है:
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();
}
}
और यह कैसे मैं कक्षा से ऊपर कहते हैं:
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 हमने इस दृष्टिकोण को पूरी तरह से छोड़ दिया और कोड के माध्यम से मानचित्र पर एक निश्चित पिन का चयन किया। –