Book Image

Learning Android Google Maps

Book Image

Learning Android Google Maps

Overview of this book

This book helps you to overcome the most common problems faced by users and helps you create a successful map application without any hassle. The book starts with a brief description of how to set up an environment and obtain an API key to create your map application. This book will teach you about adding markers, overlays, and information windows to the map in detail. You will then dive deep into customizing various types of maps and working with location data and Google Street view. By the end of this book, you will be able to create succinct map applications in Android using Google maps efficiently.
Table of Contents (18 chapters)
Learning Android Google Maps
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Animating the camera


In the previous sections, we used the moveCamera() method on the GoogleMap object. It changes the camera and updates the view immediately. You may have noted that, during the transformation, there is no animation and it is not smooth. So, in order to make smoother transformations, we need to use animations.

Using animation is very simple. Replace the moveCamera() method with the animateCamera() method. It would be similar to:

        map.animateCamera(CameraUpdateFactory.scrollBy(10,0));

To get more control over the animation, we can use the same animateCamera() method with more parameters. They are as follows:

  • The CameraUpdate object: This is the first parameter, which is same as the one used in the moveCamera() method.

  • Duration: This is the time interval for which the animation should exist. It should be specified as the integer type.

  • Callback: A callback method is called when the animation is being executed. It is optional. The callback methods are given by:

    onFinish():...