i am implementing long click to get latlang on mapview, i referred this tutorial. but i am getting error
here is my code:
import com.google.android.gms.vision.barcode.Barcode;
public class MyCustomMapView extends MapView {
public interface OnLongpressListener {
public void onLongpress(MapView view, Barcode.GeoPoint longpressLocation);
}
static final int LONGPRESS_THRESHOLD = 500;
private Barcode.GeoPoint lastMapCenter;
private Timer longpressTimer = new Timer();
private MyCustomMapView.OnLongpressListener longpressListener;
public MyCustomMapView(Context context) {
super(context);
}
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() {
Barcode.GeoPoint longpressLocation = getProjection().fromPixels((int)event.getX(),
(int)event.getY()); <--here -->
longpressListener.onLongpress(MyCustomMapView.this, longpressLocation);
}
}, LONGPRESS_THRESHOLD);
lastMapCenter = **getMapCenter()**;
}
if (event.getAction() == MotionEvent.ACTION_MOVE) {
if (!getMapCenter().equals(lastMapCenter)) {
longpressTimer.cancel();
}
lastMapCenter = getMapCenter();<-- here -->
}
if (event.getAction() == MotionEvent.ACTION_UP) {
longpressTimer.cancel();
}
if (event.getPointerCount() > 1) {
longpressTimer.cancel();
}
}
}
here my getProjection() and getMapCenter() cant resolve, i want to know why its happening, is this method deprecated, or what method i have to use instead,
and i also want to know that why its barcode.GeoPoint, why my program importing
import com.google.android.gms.vision.barcode.Barcode; instead of
import com.google.maps.GeoPoint;