How to determine if moveCamera is complete in the Google map service?

I want to take a picture when moveCamera is finished.

I used the onCamerachange () and onMapLoaded () functions for the Googlemap object,

But this time of the callback handler does not fit my intention.

I want to move the camera to what I want, and when the map download is finished, you want to take a screenshot.

Who do you guys know how I can do this?

Thanks.

==================================================== ==

+ MYSOLUTION

Actually, I want to implement a breakdown callback () function, which is supported in google API javascript. But, as a result, there is no function that would fully fulfill this function.

The OnMapLoaded () callback function is run only once when the map is loaded first.

OnCameraChanged() OnCancallableCallback .

,

...
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);
}

, , onMapLoaded() .

.

+4
2

:

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() {

            }
        });

, GoogleMap.animateCamera(cameraUpdate, duration, callback), :

CameraUpdate

CameraUpdate, , . , GoogleMap.CancellableCallback. onCancel() onFinished(). :

onFinish()

, .

OnCancel()

, stopAnimation() .

, GoogleMap.stopAnimation().

: API Google Maps Android

+16

, , onCameraChange() onMapLoaded(). - onMapLoaded(). , . .

:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //...All of the other important things you have here

    //Instantiate the map object using the support library
    map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
        .getMap();

    map.getMapAsync(this);

    //Add the callback to your map object
    map.setOnMapLoadedCallback(this);

}

@Override
public void onMapLoaded(){
    //Perform screenshot here
}

.

@Override
public void onCameraChange(){

    //Constant for our time. I would put this below your class declaration
    private static final int DELAY_TIME_IN_MILLI = 3000;

    //Here is the handler for waiting
    mMap.postDelayed(new Runnable() {

                //This function runs after the time allotted below 
                @Override
                public void run() {

                    //Call your screenshot function here
                    takeScreenShot();
                }
            },DELAY_TIME_IN_MILLI);            //Our delay
}
0

Source: https://habr.com/ru/post/1617114/


All Articles