Learning Android Google Maps

Book description

Integrate Google Maps with your Android application to offer feature-rich and interactive maps

About This Book

  • Set up the development environment and obtain the Google API key to create your first map application
  • Create a cutting edge Google maps application by implementing all the concepts learned
  • A step-by-step tutorial guide that is full of pragmatic examples

Who This Book Is For

If you are an Android developer and want to integrate maps into your application, then this book is definitely for you. This book is intended for novice Android application developers who would like to get up and running with map rich applications using Google Maps. Some basic development experience would be helpful but it's not a mandate.

What You Will Learn

  • Get to know about the basic development environment setup needed to create a successful map application
  • Generate an SHA1 fingerprint, obtain an API key, and create a basic map application
  • Detect different types of maps and implement them in your application
  • Add information to your map such as markers, overlays, information windows, and shapes
  • Explore the interaction with maps and work with gestures
  • Change the different camera views in your map application
  • Work with real-time GPS location data and implementing it in your application
  • Apply Street View and integrate the StreetViewPanoroma fragment to your application
  • Employ the native Google maps application to solve some of the tasks using intents
  • Create a cutting edge Google maps application by implementing all the concepts learned

In Detail

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.

Style and approach

The book is tailored for the reader with a fundamental approach to Android Google Maps providing a step-by-step introduction to Android Google Maps. It focuses on simple, easy-to-understand examples that are pragmatic and serve as useful basis for real-world applications. Different topics are approached in a bottom-up fashion, gradually going from the simplest foundations to the most advanced features.

Downloading the example code for this book You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Publisher resources

Download Example Code

Table of contents

  1. Learning Android Google Maps
    1. Table of Contents
    2. Learning Android Google Maps
    3. Credits
    4. About the Author
    5. About the Reviewer
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers, and more
        1. Why subscribe?
        2. Free access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Downloading the color images of this book
        3. Errata
        4. Piracy
        5. Questions
    8. 1. Setting Up the Development Environment
      1. The importance of Android Google Maps
        1. An example of a map application
      2. IDEs for developing Android applications
      3. Android Studio
      4. System requirements for Android Studio
        1. Eclipse
        2. Choosing one IDE over another
      5. Setting up Android Studio
        1. Windows
        2. Mac OS X
        3. Linux
        4. Setting up Eclipse with the ADT plugin
        5. Windows
        6. Mac OS X
        7. Linux
        8. Downloading and setting up Google Play services
        9. Downloading the Google APIs System Image
      6. Setting up AVD for testing
        1. Setting up AVD from Android Studio
        2. Setting up AVD from Eclipse
      7. Exploring Android Studio
        1. Creating a sample application
        2. Exporting the Android application as APK
      8. Additional helpful stuff
        1. Using Android Debug Bridge
        2. Configuring JAVA environment variables
        3. Android API levels
      9. Self-test questions
      10. Summary
    9. 2. Configuring an API Key and Creating Our First Map Application
      1. Generating the SHA1 fingerprint
        1. Windows
        2. Linux
        3. Mac OS X
      2. Registering in the Google Developer Console
      3. Configuring Google Play services
        1. Android Studio
        2. Eclipse
      4. Adding permissions and defining the API key
        1. Adding permissions
          1. INTERNET
          4. READ_GSERVICES
        2. Specifying the Google Play services version
        3. Specifying the version 2 of OpenGL ES
        4. Defining the API key
      5. Creating our first map application
        1. Working with a layout
        2. Optional (for old APIs)
        3. Working with the Activity class
        4. Optional (for old APIs)
        5. Adding MapFragment programatically
          1. activity_maps.xml – code 3
        6. Optional – for older APIs
        7. Using the callback method
        8. The GoogleMap object
      6. Common problems and solutions
      7. Self-test questions
      8. Summary
    10. 3. Working with Different Map Types
      1. The need for different types of maps
      2. Delving into different types of maps and their differences
        1. Normal map
        2. Satellite map
        3. Hybrid map
        4. Terrain map
      3. Implementing different types of maps
        1. Using a normal map
        2. Using a satellite map
        3. Using a hybrid map
        4. Using a terrain map
        5. What if I don't need anything?
      4. Working with indoor maps
      5. Using the lite mode
      6. Map types and constants
      7. Self-test questions
      8. Summary
    11. 4. Adding Information to Maps
      1. Importance of adding information to a map
      2. Adding information with markers
        1. How to add a marker?
        2. Customizing the marker
          1. Changing the marker color
          2. Changing the marker opacity
          3. Using a custom image as a marker
          4. Flattening a marker
          5. Rotating a marker
          6. Hiding a marker
        3. Employing marker events
          1. Marker click events
          2. Marker drag events
      3. Expanding markers with information windows
        1. How to add an information window?
        2. Showing/hiding an information window programmatically
        3. Creating custom information windows
      4. Working with shapes
        1. Polyline
          1. Creating a polyline
        2. Polygons
          1. Creating a polygon
          2. Creating a hollow polygon
        3. Circles
        4. Creating a circle
        5. Customizing the appearance of shapes
          1. Changing the stroke color
          2. Using a fill color
          3. Changing the stroke width
          4. Geodesic segments
          5. Z-Index
          6. Changing the visibility
      5. Using overlays
        1. Ground overlays
          1. Adding a ground overlay
          2. Positioning a ground overlay
        2. Tile overlays
          1. Tile coordinates and zoom levels
          2. Removing a tile overlay
          3. Clearing the cache
      6. Self-test questions
      7. Summary
    12. 5. Interacting with a Map
      1. Need for interaction with a map
      2. Working with UI controls
        1. Zoom controls
        2. Compass
        3. The My Location button
        4. Level picker
        5. Custom applications
      3. Working with the map toolbar
      4. Working with gestures
        1. Zoom gestures
          1. Double tap
          2. Two finger tap
          3. Two finger pinch/stretch (pinch to zoom)
          4. One finger zoom
        2. Scroll gestures
        3. Tilt gestures
        4. Rotate gestures
      5. Disabling/Enabling UI controls and gestures with XML attributes
      6. Disabling/enabling the UI controls and gestures with the GoogleMapOptions object
      7. Working with map events
        1. Map click/long click events
        2. Camera change events
        3. Indoor map events
      8. Using a Projection class
      9. Creating a custom application
      10. Self-test questions
      11. Summary
    13. 6. Working with Custom Views
      1. The need for different camera views
      2. Working with camera positions
        1. Target
        2. Zoom
        3. Bearing
        4. Tilt
      3. Moving the camera
        1. Changing the zoom level in the current position
        2. Changing the camera position
          1. Using the CameraPosition class
        3. Setting boundaries
        4. Panning the map
      4. Animating the camera
      5. Map padding
      6. Self-test questions
      7. Summary
    14. 7. Working with Location Data
      1. The need for location data
      2. Prerequisites
        3. Using the my location layer
        4. Using the Android Location API
        5. Using the Google Play services Location API
      3. Working with the Android Location API
      4. Working with the Google Play services Location API
        1. Getting the last known location
        2. Location updates
        3. Using reverse geocoding
        4. Working with Geofences
      5. Integrating location data with maps
      6. Self-test questions
      7. Summary
    15. 8. Know about the Street View
      1. About Google Street View
      2. Prerequisites
      3. Implementing StreetViewPanoramaFragment
        1. Adding StreetViewPanoramaFragment programmatically
      4. Customizing StreetViewPanorama
        1. Disabling/enabling pan gestures
        2. Disabling/enabling user navigation
        3. Disabling/enabling zoom gestures
        4. Disabling/enabling the street name
        5. Working with click events
        6. Listening to panorama change events
      5. Using custom camera views
      6. Other functions
        1. Orientation to point
        2. Point to orientation
        3. Getting the location
      7. Self-test questions
      8. Summary
    16. 9. Google Maps Intents
      1. The need for Google Maps Intents
      2. Defining Intent requests
        1. Action
        2. URI
        3. Package
      3. Display maps
        1. Display maps with a specified zoom level
      4. Searching for a location
        1. Advanced search
        2. Label location
      5. Using navigation
      6. Displaying StreetViewPanorama
      7. Self-test questions
      8. Summary
    17. 10. Creating a Custom Map Application
      1. What the custom application does
      2. What additional libraries/classes do we use
      3. Prerequisites
        1. Adding dependencies
        2. Using the material design icons
        3. Adding permissions
        4. Defining the API key and Google Play services version
      4. Implementation
        1. Defining the app theme
        2. Defining strings
        3. Defining and creating a database
        4. Creating layouts
        5. Creating activities and fragments
      5. Summary
    18. A. Answers to Self-test Questions
      1. Chapter 1, Setting Up the Development Environment
      2. Chapter 2, Configuring an API Key and Creating Our First Map Application
      3. Chapter 3, Working with Different Map Types
      4. Chapter 4, Adding Information to Maps
      5. Chapter 5, Interacting with a Map
      6. Chapter 6, Working with Custom Views
      7. Chapter 7, Working with Location Data
      8. Chapter 8, Knowing about the Street View
      9. Chapter 9, Google Maps Intents
    19. Index

Product information

  • Title: Learning Android Google Maps
  • Author(s): Raj Amal W.
  • Release date: September 2015
  • Publisher(s): Packt Publishing
  • ISBN: 9781849698863