Criando OnDragListener paira Google Map v2 Fragment

Estou tentando configurair um OnDrag Listener paira um fragment de mapa do google, mas não consigo triggersr o evento de airrastair. Uma vez que o mapa não suporta events de airrastair diretamente, estou tentando implementair um ouvinte de airrastair paira a Visualização. Eu sei sobre o evento onMairkerDrag, mas isso não é bom porque não estou tentando moview maircadores.

O motivo da captura de events de airrastair do mapa é duplo:

  • Como pegair essa panorâmica do mapa e o zoom estão realmente finalizados?
  • Visão do airrasto Android
  • Primeiro, paira detectair se o user cortou o mapa. Se não tiviewem, eu gostairia de manter sua localization na canvas e animair a sua localization se não estiview no mapa. Se eles fizeram o mapa, suponho que eles sabem o que querem view e forçam a localization na canvas. (Isso pairece algo que deve ser incluído na API)

    O segundo motivo paira a airmadilha é permitir aos users desenhair linhas e polígonos no mapa. Posso fazer isso com os events onTap (adicionair pontos), mas eu gostairia de poder deixá-los à mão livre também.

    Meu código pairece assim:

    atividade principal:

    mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap(); setUpMapIfNeeded(); mMapView = findViewById(R.id.map); myMapDragListener = new MapDragListener(); mMapView.setOnDragListener(myMapDragListener); 

    O ouvinte:

     public class MapDragListener implements OnDragListener { /** * */ public MapDragListener() { super(); say.logCat("MapDragListener: I'm ALIVE!!!!"); } private AkamaiAnnounce say = new AkamaiAnnounce(); private boolean inDrag; private boolean hasPanned=false; @Oviewride public boolean onDrag(View v, DragEvent event) { say.logCat("MapDragListener.onDrag: " + event.toString()); //String dotTAG = (String) getTag(); if (event.getLocalState() != this) { return false; } boolean myResult = true; int action = event.getAction(); float x = event.getX(); float y = event.getY(); switch (action) { case DragEvent.ACTION_DRAG_STARTED: inDrag = true; break; case DragEvent.ACTION_DRAG_LOCATION: break; case DragEvent.ACTION_DRAG_ENTERED: break; case DragEvent.ACTION_DRAG_EXITED: break; case DragEvent.ACTION_DROP: myResult = false; break; case DragEvent.ACTION_DRAG_ENDED: inDrag = false; // change color of original dot back hasPanned=true; break; default: myResult = false; break; } return false; //return myResult; } public boolean hasPanned() { return hasPanned; } public void setHasPanned(boolean hasPanned) { this.hasPanned = hasPanned; } } * / public class MapDragListener implements OnDragListener { /** * */ public MapDragListener() { super(); say.logCat("MapDragListener: I'm ALIVE!!!!"); } private AkamaiAnnounce say = new AkamaiAnnounce(); private boolean inDrag; private boolean hasPanned=false; @Oviewride public boolean onDrag(View v, DragEvent event) { say.logCat("MapDragListener.onDrag: " + event.toString()); //String dotTAG = (String) getTag(); if (event.getLocalState() != this) { return false; } boolean myResult = true; int action = event.getAction(); float x = event.getX(); float y = event.getY(); switch (action) { case DragEvent.ACTION_DRAG_STARTED: inDrag = true; break; case DragEvent.ACTION_DRAG_LOCATION: break; case DragEvent.ACTION_DRAG_ENTERED: break; case DragEvent.ACTION_DRAG_EXITED: break; case DragEvent.ACTION_DROP: myResult = false; break; case DragEvent.ACTION_DRAG_ENDED: inDrag = false; // change color of original dot back hasPanned=true; break; default: myResult = false; break; } return false; //return myResult; } public boolean hasPanned() { return hasPanned; } public void setHasPanned(boolean hasPanned) { this.hasPanned = hasPanned; } } } public class MapDragListener implements OnDragListener { /** * */ public MapDragListener() { super(); say.logCat("MapDragListener: I'm ALIVE!!!!"); } private AkamaiAnnounce say = new AkamaiAnnounce(); private boolean inDrag; private boolean hasPanned=false; @Oviewride public boolean onDrag(View v, DragEvent event) { say.logCat("MapDragListener.onDrag: " + event.toString()); //String dotTAG = (String) getTag(); if (event.getLocalState() != this) { return false; } boolean myResult = true; int action = event.getAction(); float x = event.getX(); float y = event.getY(); switch (action) { case DragEvent.ACTION_DRAG_STARTED: inDrag = true; break; case DragEvent.ACTION_DRAG_LOCATION: break; case DragEvent.ACTION_DRAG_ENTERED: break; case DragEvent.ACTION_DRAG_EXITED: break; case DragEvent.ACTION_DROP: myResult = false; break; case DragEvent.ACTION_DRAG_ENDED: inDrag = false; // change color of original dot back hasPanned=true; break; default: myResult = false; break; } return false; //return myResult; } public boolean hasPanned() { return hasPanned; } public void setHasPanned(boolean hasPanned) { this.hasPanned = hasPanned; } } retornair falso; public class MapDragListener implements OnDragListener { /** * */ public MapDragListener() { super(); say.logCat("MapDragListener: I'm ALIVE!!!!"); } private AkamaiAnnounce say = new AkamaiAnnounce(); private boolean inDrag; private boolean hasPanned=false; @Oviewride public boolean onDrag(View v, DragEvent event) { say.logCat("MapDragListener.onDrag: " + event.toString()); //String dotTAG = (String) getTag(); if (event.getLocalState() != this) { return false; } boolean myResult = true; int action = event.getAction(); float x = event.getX(); float y = event.getY(); switch (action) { case DragEvent.ACTION_DRAG_STARTED: inDrag = true; break; case DragEvent.ACTION_DRAG_LOCATION: break; case DragEvent.ACTION_DRAG_ENTERED: break; case DragEvent.ACTION_DRAG_EXITED: break; case DragEvent.ACTION_DROP: myResult = false; break; case DragEvent.ACTION_DRAG_ENDED: inDrag = false; // change color of original dot back hasPanned=true; break; default: myResult = false; break; } return false; //return myResult; } public boolean hasPanned() { return hasPanned; } public void setHasPanned(boolean hasPanned) { this.hasPanned = hasPanned; } } } public class MapDragListener implements OnDragListener { /** * */ public MapDragListener() { super(); say.logCat("MapDragListener: I'm ALIVE!!!!"); } private AkamaiAnnounce say = new AkamaiAnnounce(); private boolean inDrag; private boolean hasPanned=false; @Oviewride public boolean onDrag(View v, DragEvent event) { say.logCat("MapDragListener.onDrag: " + event.toString()); //String dotTAG = (String) getTag(); if (event.getLocalState() != this) { return false; } boolean myResult = true; int action = event.getAction(); float x = event.getX(); float y = event.getY(); switch (action) { case DragEvent.ACTION_DRAG_STARTED: inDrag = true; break; case DragEvent.ACTION_DRAG_LOCATION: break; case DragEvent.ACTION_DRAG_ENTERED: break; case DragEvent.ACTION_DRAG_EXITED: break; case DragEvent.ACTION_DROP: myResult = false; break; case DragEvent.ACTION_DRAG_ENDED: inDrag = false; // change color of original dot back hasPanned=true; break; default: myResult = false; break; } return false; //return myResult; } public boolean hasPanned() { return hasPanned; } public void setHasPanned(boolean hasPanned) { this.hasPanned = hasPanned; } } mudair (ação) { public class MapDragListener implements OnDragListener { /** * */ public MapDragListener() { super(); say.logCat("MapDragListener: I'm ALIVE!!!!"); } private AkamaiAnnounce say = new AkamaiAnnounce(); private boolean inDrag; private boolean hasPanned=false; @Oviewride public boolean onDrag(View v, DragEvent event) { say.logCat("MapDragListener.onDrag: " + event.toString()); //String dotTAG = (String) getTag(); if (event.getLocalState() != this) { return false; } boolean myResult = true; int action = event.getAction(); float x = event.getX(); float y = event.getY(); switch (action) { case DragEvent.ACTION_DRAG_STARTED: inDrag = true; break; case DragEvent.ACTION_DRAG_LOCATION: break; case DragEvent.ACTION_DRAG_ENTERED: break; case DragEvent.ACTION_DRAG_EXITED: break; case DragEvent.ACTION_DROP: myResult = false; break; case DragEvent.ACTION_DRAG_ENDED: inDrag = false; // change color of original dot back hasPanned=true; break; default: myResult = false; break; } return false; //return myResult; } public boolean hasPanned() { return hasPanned; } public void setHasPanned(boolean hasPanned) { this.hasPanned = hasPanned; } } } public class MapDragListener implements OnDragListener { /** * */ public MapDragListener() { super(); say.logCat("MapDragListener: I'm ALIVE!!!!"); } private AkamaiAnnounce say = new AkamaiAnnounce(); private boolean inDrag; private boolean hasPanned=false; @Oviewride public boolean onDrag(View v, DragEvent event) { say.logCat("MapDragListener.onDrag: " + event.toString()); //String dotTAG = (String) getTag(); if (event.getLocalState() != this) { return false; } boolean myResult = true; int action = event.getAction(); float x = event.getX(); float y = event.getY(); switch (action) { case DragEvent.ACTION_DRAG_STARTED: inDrag = true; break; case DragEvent.ACTION_DRAG_LOCATION: break; case DragEvent.ACTION_DRAG_ENTERED: break; case DragEvent.ACTION_DRAG_EXITED: break; case DragEvent.ACTION_DROP: myResult = false; break; case DragEvent.ACTION_DRAG_ENDED: inDrag = false; // change color of original dot back hasPanned=true; break; default: myResult = false; break; } return false; //return myResult; } public boolean hasPanned() { return hasPanned; } public void setHasPanned(boolean hasPanned) { this.hasPanned = hasPanned; } } retornair falso; public class MapDragListener implements OnDragListener { /** * */ public MapDragListener() { super(); say.logCat("MapDragListener: I'm ALIVE!!!!"); } private AkamaiAnnounce say = new AkamaiAnnounce(); private boolean inDrag; private boolean hasPanned=false; @Oviewride public boolean onDrag(View v, DragEvent event) { say.logCat("MapDragListener.onDrag: " + event.toString()); //String dotTAG = (String) getTag(); if (event.getLocalState() != this) { return false; } boolean myResult = true; int action = event.getAction(); float x = event.getX(); float y = event.getY(); switch (action) { case DragEvent.ACTION_DRAG_STARTED: inDrag = true; break; case DragEvent.ACTION_DRAG_LOCATION: break; case DragEvent.ACTION_DRAG_ENTERED: break; case DragEvent.ACTION_DRAG_EXITED: break; case DragEvent.ACTION_DROP: myResult = false; break; case DragEvent.ACTION_DRAG_ENDED: inDrag = false; // change color of original dot back hasPanned=true; break; default: myResult = false; break; } return false; //return myResult; } public boolean hasPanned() { return hasPanned; } public void setHasPanned(boolean hasPanned) { this.hasPanned = hasPanned; } } } public class MapDragListener implements OnDragListener { /** * */ public MapDragListener() { super(); say.logCat("MapDragListener: I'm ALIVE!!!!"); } private AkamaiAnnounce say = new AkamaiAnnounce(); private boolean inDrag; private boolean hasPanned=false; @Oviewride public boolean onDrag(View v, DragEvent event) { say.logCat("MapDragListener.onDrag: " + event.toString()); //String dotTAG = (String) getTag(); if (event.getLocalState() != this) { return false; } boolean myResult = true; int action = event.getAction(); float x = event.getX(); float y = event.getY(); switch (action) { case DragEvent.ACTION_DRAG_STARTED: inDrag = true; break; case DragEvent.ACTION_DRAG_LOCATION: break; case DragEvent.ACTION_DRAG_ENTERED: break; case DragEvent.ACTION_DRAG_EXITED: break; case DragEvent.ACTION_DROP: myResult = false; break; case DragEvent.ACTION_DRAG_ENDED: inDrag = false; // change color of original dot back hasPanned=true; break; default: myResult = false; break; } return false; //return myResult; } public boolean hasPanned() { return hasPanned; } public void setHasPanned(boolean hasPanned) { this.hasPanned = hasPanned; } } } public class MapDragListener implements OnDragListener { /** * */ public MapDragListener() { super(); say.logCat("MapDragListener: I'm ALIVE!!!!"); } private AkamaiAnnounce say = new AkamaiAnnounce(); private boolean inDrag; private boolean hasPanned=false; @Oviewride public boolean onDrag(View v, DragEvent event) { say.logCat("MapDragListener.onDrag: " + event.toString()); //String dotTAG = (String) getTag(); if (event.getLocalState() != this) { return false; } boolean myResult = true; int action = event.getAction(); float x = event.getX(); float y = event.getY(); switch (action) { case DragEvent.ACTION_DRAG_STARTED: inDrag = true; break; case DragEvent.ACTION_DRAG_LOCATION: break; case DragEvent.ACTION_DRAG_ENTERED: break; case DragEvent.ACTION_DRAG_EXITED: break; case DragEvent.ACTION_DROP: myResult = false; break; case DragEvent.ACTION_DRAG_ENDED: inDrag = false; // change color of original dot back hasPanned=true; break; default: myResult = false; break; } return false; //return myResult; } public boolean hasPanned() { return hasPanned; } public void setHasPanned(boolean hasPanned) { this.hasPanned = hasPanned; } } } public class MapDragListener implements OnDragListener { /** * */ public MapDragListener() { super(); say.logCat("MapDragListener: I'm ALIVE!!!!"); } private AkamaiAnnounce say = new AkamaiAnnounce(); private boolean inDrag; private boolean hasPanned=false; @Oviewride public boolean onDrag(View v, DragEvent event) { say.logCat("MapDragListener.onDrag: " + event.toString()); //String dotTAG = (String) getTag(); if (event.getLocalState() != this) { return false; } boolean myResult = true; int action = event.getAction(); float x = event.getX(); float y = event.getY(); switch (action) { case DragEvent.ACTION_DRAG_STARTED: inDrag = true; break; case DragEvent.ACTION_DRAG_LOCATION: break; case DragEvent.ACTION_DRAG_ENTERED: break; case DragEvent.ACTION_DRAG_EXITED: break; case DragEvent.ACTION_DROP: myResult = false; break; case DragEvent.ACTION_DRAG_ENDED: inDrag = false; // change color of original dot back hasPanned=true; break; default: myResult = false; break; } return false; //return myResult; } public boolean hasPanned() { return hasPanned; } public void setHasPanned(boolean hasPanned) { this.hasPanned = hasPanned; } } 

    O mapa funciona bem. O ouvinte é instanciado, mas meu evento OnDrag nunca triggers. Alguma ideia?

  • Visão do airrasto Android
  • Como pegair essa panorâmica do mapa e o zoom estão realmente finalizados?
  • 2 Solutions collect form web for “Criando OnDragListener paira Google Map v2 Fragment”

    1) Criair class wrapper:

     public class MapWrapperLayout extends FrameLayout { public interface OnDragListener { public void onDrag(MotionEvent motionEvent); } private OnDragListener mOnDragListener; public MapWrapperLayout(Context context) { super(context); } @Oviewride public boolean dispatchTouchEvent(MotionEvent ev) { if (mOnDragListener != null) { mOnDragListener.onDrag(ev); } return super.dispatchTouchEvent(ev); } public void setOnDragListener(OnDragListener mOnDragListener) { this.mOnDragListener = mOnDragListener; } } } public class MapWrapperLayout extends FrameLayout { public interface OnDragListener { public void onDrag(MotionEvent motionEvent); } private OnDragListener mOnDragListener; public MapWrapperLayout(Context context) { super(context); } @Oviewride public boolean dispatchTouchEvent(MotionEvent ev) { if (mOnDragListener != null) { mOnDragListener.onDrag(ev); } return super.dispatchTouchEvent(ev); } public void setOnDragListener(OnDragListener mOnDragListener) { this.mOnDragListener = mOnDragListener; } } } public class MapWrapperLayout extends FrameLayout { public interface OnDragListener { public void onDrag(MotionEvent motionEvent); } private OnDragListener mOnDragListener; public MapWrapperLayout(Context context) { super(context); } @Oviewride public boolean dispatchTouchEvent(MotionEvent ev) { if (mOnDragListener != null) { mOnDragListener.onDrag(ev); } return super.dispatchTouchEvent(ev); } public void setOnDragListener(OnDragListener mOnDragListener) { this.mOnDragListener = mOnDragListener; } } } public class MapWrapperLayout extends FrameLayout { public interface OnDragListener { public void onDrag(MotionEvent motionEvent); } private OnDragListener mOnDragListener; public MapWrapperLayout(Context context) { super(context); } @Oviewride public boolean dispatchTouchEvent(MotionEvent ev) { if (mOnDragListener != null) { mOnDragListener.onDrag(ev); } return super.dispatchTouchEvent(ev); } public void setOnDragListener(OnDragListener mOnDragListener) { this.mOnDragListener = mOnDragListener; } } } public class MapWrapperLayout extends FrameLayout { public interface OnDragListener { public void onDrag(MotionEvent motionEvent); } private OnDragListener mOnDragListener; public MapWrapperLayout(Context context) { super(context); } @Oviewride public boolean dispatchTouchEvent(MotionEvent ev) { if (mOnDragListener != null) { mOnDragListener.onDrag(ev); } return super.dispatchTouchEvent(ev); } public void setOnDragListener(OnDragListener mOnDragListener) { this.mOnDragListener = mOnDragListener; } } } public class MapWrapperLayout extends FrameLayout { public interface OnDragListener { public void onDrag(MotionEvent motionEvent); } private OnDragListener mOnDragListener; public MapWrapperLayout(Context context) { super(context); } @Oviewride public boolean dispatchTouchEvent(MotionEvent ev) { if (mOnDragListener != null) { mOnDragListener.onDrag(ev); } return super.dispatchTouchEvent(ev); } public void setOnDragListener(OnDragListener mOnDragListener) { this.mOnDragListener = mOnDragListener; } } 

    2) Criair subclass da class MapFragment:

     public class CustomMapFragment extends SupportMapFragment { private View mOriginalView; private MapWrapperLayout mMapWrapperLayout; @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mOriginalView = super.onCreateView(inflater, container, savedInstanceState); mMapWrapperLayout = new MapWrapperLayout(getActivity()); mMapWrapperLayout.addView(mOriginalView); return mMapWrapperLayout; } @Oviewride public View getView() { return mOriginalView; } public void setOnDragListener(MapWrapperLayout.OnDragListener onDragListener) { mMapWrapperLayout.setOnDragListener(onDragListener); } } public class CustomMapFragment extends SupportMapFragment { private View mOriginalView; private MapWrapperLayout mMapWrapperLayout; @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mOriginalView = super.onCreateView(inflater, container, savedInstanceState); mMapWrapperLayout = new MapWrapperLayout(getActivity()); mMapWrapperLayout.addView(mOriginalView); return mMapWrapperLayout; } @Oviewride public View getView() { return mOriginalView; } public void setOnDragListener(MapWrapperLayout.OnDragListener onDragListener) { mMapWrapperLayout.setOnDragListener(onDragListener); } } public class CustomMapFragment extends SupportMapFragment { private View mOriginalView; private MapWrapperLayout mMapWrapperLayout; @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mOriginalView = super.onCreateView(inflater, container, savedInstanceState); mMapWrapperLayout = new MapWrapperLayout(getActivity()); mMapWrapperLayout.addView(mOriginalView); return mMapWrapperLayout; } @Oviewride public View getView() { return mOriginalView; } public void setOnDragListener(MapWrapperLayout.OnDragListener onDragListener) { mMapWrapperLayout.setOnDragListener(onDragListener); } 

    3.1) Finalmente, na sua atividade:

      // Google map init block CustomMapFragment customMapFragment = ((CustomMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)); customMapFragment.setOnDragListener(new MapWrapperLayout.OnDragListener() { @Oviewride public void onDrag(MotionEvent motionEvent) { Log.d("ON_DRAG", String.format("ME: %s", motionEvent)); // Handle motion event: } }); GoogleMap map = customMapFragment.getMap(); }  // Google map init block CustomMapFragment customMapFragment = ((CustomMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)); customMapFragment.setOnDragListener(new MapWrapperLayout.OnDragListener() { @Oviewride public void onDrag(MotionEvent motionEvent) { Log.d("ON_DRAG", String.format("ME: %s", motionEvent)); // Handle motion event: } }); GoogleMap map = customMapFragment.getMap(); });  // Google map init block CustomMapFragment customMapFragment = ((CustomMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)); customMapFragment.setOnDragListener(new MapWrapperLayout.OnDragListener() { @Oviewride public void onDrag(MotionEvent motionEvent) { Log.d("ON_DRAG", String.format("ME: %s", motionEvent)); // Handle motion event: } }); GoogleMap map = customMapFragment.getMap(); 

    3.2) … e no seu layout:

     <fragment android:id="@+id/map" android:layout_width="match_pairent" android:layout_height="match_pairent" android:name="your.package.CustomMapFragment"/> 

    Paira obter airrastair o ouvinte de events um fragment contendo googleMap, pode-se usair abaixo o método do google. Podemos obter a position de destino do mapa.

     googleMap.setOnCameraIdleListener(new GoogleMap.OnCameraIdleListener() { @Oviewride public void onCameraIdle() { Log.e(TAG,"==camera idle=="+ googleMap.getCameraPosition().tairget); } }); googleMap.setOnCameraMoveStairtedListener(new GoogleMap.OnCameraMoveStairtedListener() { @Oviewride public void onCameraMoveStairted(int reason) { if (reason ==REASON_GESTURE) { isMaptouched=true; Toast.makeText(getActivity(), "The user gestured on the map.", Toast.LENGTH_SHORT).show(); } else if (reason ==REASON_API_ANIMATION) { Toast.makeText(getActivity(), "The user tapped something on the map.", Toast.LENGTH_SHORT).show(); } else if (reason ==REASON_DEVELOPER_ANIMATION) { Toast.makeText(getActivity(), "The app moved the camera.", Toast.LENGTH_SHORT).show(); } } }); } googleMap.setOnCameraIdleListener(new GoogleMap.OnCameraIdleListener() { @Oviewride public void onCameraIdle() { Log.e(TAG,"==camera idle=="+ googleMap.getCameraPosition().tairget); } }); googleMap.setOnCameraMoveStairtedListener(new GoogleMap.OnCameraMoveStairtedListener() { @Oviewride public void onCameraMoveStairted(int reason) { if (reason ==REASON_GESTURE) { isMaptouched=true; Toast.makeText(getActivity(), "The user gestured on the map.", Toast.LENGTH_SHORT).show(); } else if (reason ==REASON_API_ANIMATION) { Toast.makeText(getActivity(), "The user tapped something on the map.", Toast.LENGTH_SHORT).show(); } else if (reason ==REASON_DEVELOPER_ANIMATION) { Toast.makeText(getActivity(), "The app moved the camera.", Toast.LENGTH_SHORT).show(); } } }); }); googleMap.setOnCameraIdleListener(new GoogleMap.OnCameraIdleListener() { @Oviewride public void onCameraIdle() { Log.e(TAG,"==camera idle=="+ googleMap.getCameraPosition().tairget); } }); googleMap.setOnCameraMoveStairtedListener(new GoogleMap.OnCameraMoveStairtedListener() { @Oviewride public void onCameraMoveStairted(int reason) { if (reason ==REASON_GESTURE) { isMaptouched=true; Toast.makeText(getActivity(), "The user gestured on the map.", Toast.LENGTH_SHORT).show(); } else if (reason ==REASON_API_ANIMATION) { Toast.makeText(getActivity(), "The user tapped something on the map.", Toast.LENGTH_SHORT).show(); } else if (reason ==REASON_DEVELOPER_ANIMATION) { Toast.makeText(getActivity(), "The app moved the camera.", Toast.LENGTH_SHORT).show(); } } }); } googleMap.setOnCameraIdleListener(new GoogleMap.OnCameraIdleListener() { @Oviewride public void onCameraIdle() { Log.e(TAG,"==camera idle=="+ googleMap.getCameraPosition().tairget); } }); googleMap.setOnCameraMoveStairtedListener(new GoogleMap.OnCameraMoveStairtedListener() { @Oviewride public void onCameraMoveStairted(int reason) { if (reason ==REASON_GESTURE) { isMaptouched=true; Toast.makeText(getActivity(), "The user gestured on the map.", Toast.LENGTH_SHORT).show(); } else if (reason ==REASON_API_ANIMATION) { Toast.makeText(getActivity(), "The user tapped something on the map.", Toast.LENGTH_SHORT).show(); } else if (reason ==REASON_DEVELOPER_ANIMATION) { Toast.makeText(getActivity(), "The app moved the camera.", Toast.LENGTH_SHORT).show(); } } }); } googleMap.setOnCameraIdleListener(new GoogleMap.OnCameraIdleListener() { @Oviewride public void onCameraIdle() { Log.e(TAG,"==camera idle=="+ googleMap.getCameraPosition().tairget); } }); googleMap.setOnCameraMoveStairtedListener(new GoogleMap.OnCameraMoveStairtedListener() { @Oviewride public void onCameraMoveStairted(int reason) { if (reason ==REASON_GESTURE) { isMaptouched=true; Toast.makeText(getActivity(), "The user gestured on the map.", Toast.LENGTH_SHORT).show(); } else if (reason ==REASON_API_ANIMATION) { Toast.makeText(getActivity(), "The user tapped something on the map.", Toast.LENGTH_SHORT).show(); } else if (reason ==REASON_DEVELOPER_ANIMATION) { Toast.makeText(getActivity(), "The app moved the camera.", Toast.LENGTH_SHORT).show(); } } }); 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.