2

How can I handle event when I finished moving camera on google map? I intend to take the last coordinate at the center of the map after I finished looking for locations, then capture the last location that showing at the center of the map.

Thank you.

zamroni hamim
  • 545
  • 1
  • 6
  • 21
  • Sorry, I kind of new on this. I've tried oncamerachanged() event on the map to get address using geocoder, and of course it became very laggy when moving map around. So I'm wondering if there is a way so I can take the address only after I finished moving around the map. – zamroni hamim Feb 19 '16 at 04:40
  • Take a look here **http://stackoverflow.com/questions/13702117/how-can-i-handle-map-move-end-using-google-maps-for-android-v2**... – Trevor Feb 19 '16 at 04:53
  • I've tried above code. But basically, that code will only works when camera still moving when I'm done touching the map. Since it's under event onCameraChangeListener(). It will not work when I really slowly stop moving map around and I put my finger away from the map. – zamroni hamim Feb 20 '16 at 05:29
  • I successfully achieve my goal above by using the accepted answer at following link: https://stackoverflow.com/questions/30162835/android-google-maps-v2-execute-asynctask-when-user-stops-moving-the-camera – zamroni hamim Feb 20 '16 at 05:34

1 Answers1

1

Yes this can be done by implementing the OnCameraChangeListener in your activity

for example.

    public class ABCActivity extends Activity implements OnCameraChangeListener
    {
    @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);

            setContentView(R.layout.actiivty_abc_layout);



    }
    @Override
        public void onCameraChange(CameraPosition position) {

 /// Perform all your operations here
    }

    }
Vivek Bhardwaj
  • 530
  • 5
  • 16
  • If I just use onCameraChangeListener() on the map to get address using geocoder, and of course it became very laggy when moving map around. – zamroni hamim Feb 20 '16 at 05:30
  • well .. i dont think that there is any other way out .. ! please elaborate more about your issue.. – Vivek Bhardwaj Feb 20 '16 at 06:10
  • I do still use onCameraChangeListener(), but also using some filters so it would only trigger the function I want when the map stops moving. I successfully did this using: http://stackoverflow.com/questions/30162835/android-google-maps-v2-execute-asynctask-when-user-stops-moving-the-camera – zamroni hamim Feb 20 '16 at 06:18