當我設置觸摸偵聽器來獲取觸摸位置lat long然後當我從我的代碼中刪除觸摸偵聽器時,放大和縮小工作不起作用。那麼如何實現在谷歌地圖上放大和縮小,並獲得觸摸位置拉長?放大和縮小在我的谷歌地圖Android上不工作
我的代碼如下
mapView = (MapView) findViewById(R.id.map);
mapView.setBuiltInZoomControls(true);
mapView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
Log.i("!!!!!","*****");
//---when user lifts his finger---
if (event.getAction() == MotionEvent.ACTION_UP) {
Projection p2 = mapView.getProjection();
GeoPoint geoPoint = p2.fromPixels((int) event.getX(), (int)event.getY());
int latitude = geoPoint.getLatitudeE6();
int longitude = geoPoint.getLongitudeE6();
String aString = Integer.toString(latitude);
String aString2 = Integer.toString(longitude);
Log.i("latitude,longitude",aString+",,"+aString2);
if((latitude < -34.538238) && (latitude > -34.672182))
{
if((longitude < -58.347702) && (longitude > -58.528976))
{
Log.i("lat,long",aString+",,"+aString2);
}
else
{
Log.i("out of region",aString+",,"+aString2);
}}
Log.i("@@@@@!!!!!","*****");
}
return true;
}
});
Bang on,觸摸監聽器是問題。 @dkBose,爲什麼不接受這個答案? – Siddharth