J'ai également été la recherche d'une réponse/exemple, mais trouvé nulle part le code de travail.
Enfin, voici le code qui fonctionne pour moi:
MyMapActivity.java
public class MyMapActivity extends MapActivity
implements OnGestureListener, OnDoubleTapListener {
private MapView mapView;
@Override
public void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mapView = (MapView)findViewById(R.id.mapView);
}
@Override
public boolean onDoubleTap(MotionEvent e) {
int x = (int)e.getX(), y = (int)e.getY();;
Projection p = mapView.getProjection();
mapView.getController().animateTo(p.fromPixels(x, y));
mapView.getController().zoomIn();
return true;
}
// Here will be some autogenerated methods too
OnDoubleTap.java
public class OnDoubleTap extends MapView {
private long lastTouchTime = -1;
public OnDoubleTap(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
long thisTime = System.currentTimeMillis();
if (thisTime - lastTouchTime < ViewConfiguration.getDoubleTapTimeout()) {
// Double tap
this.getController().zoomInFixing((int) ev.getX(), (int) ev.getY());
lastTouchTime = -1;
} else {
// Too slow
lastTouchTime = thisTime;
}
}
return super.onInterceptTouchEvent(ev);
}
}
main.xml
N'oubliez pas de remplacer ici la valeur
android:apiKey
par votre
apiKey
N'oubliez pas de remplacer ici la valeur android:apiKey
par votre apiKey
.
il n'y a pas taper deux fois dans ce poste pourquoi tout le monde à ce fil redirigent particulier: | – Necronet