I want to take a snapshot when moveCamera is finished.
I used both onCamerachange() and onMapLoaded() functions to Googlemap object,
But this callback handler's timing is not fit on my intention.
I want to move camera to what I want, and when loading map is finished, want to take a screnshot.
Who do you guys know about how can I do?
Thank you.
====================================================
+MYSOLUTION
Actually, I want to implement tilesloaded() call back function that is supported on the google map API of the javascript. But, as a result, there is no function which is completely accomplished that function.
OnMapLoaded() callback function is just invoked once when the map is loaded first.
OnCameraChanged() or OnCancallableCallback is invoked before all the tiles are loaded.
So I implemented like below source code
...
mMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 10), this);
...
@Override
public void onFinish() {
mapFragment.getMapAsync(this);
}
..
@Override
public void onMapReady(GoogleMap googleMap) {
// TODO Auto-generated method stub
mMap = googleMap;// Add a marker in Sydney and move the camera
mMap.setOnMapLoadedCallback(this);
}
Now, when the camera is moved, onMapLoaded() is always invoked.
Thank you everybody.
Without clicking any button, how to directly get the current location and move the camera to it. Also, I found that there is a button on the right top of the map. When click on it, it will go to current location.
The Google Maps API provides map tiles at various zoom levels for map type imagery. Most roadmap imagery is available from zoom levels 0 to 18, for example. Satellite imagery varies more widely as this imagery is not generated, but directly photographed.
You can implement this:
mMap.animateCamera(CameraUpdateFactory.zoomTo(16), 3000, new GoogleMap.CancelableCallback() {
@Override
public void onFinish() {
//Here you can take the snapshot or whatever you want
}
@Override
public void onCancel() {
}
});
The most detailed form of this method, GoogleMap.animateCamera(cameraUpdate, duration, callback), offers three arguments:
The CameraUpdate describing where to move the camera.
callback
An object that implements GoogleMap.CancellableCallback. This generalized interface for handling tasks defines two methods onCancel()
and onFinished()
. For animation, the methods are called in the following circumstances:
Invoked if the animation goes to completion without interruption.
Invoked if the animation is interrupted by calling stopAnimation() or starting a new camera movement.
Alternatively, this can also occur if you call GoogleMap.stopAnimation().
Source: Google Maps Android API Guides
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With