Working with Your Map

Your SupportMapFragment creates a MapView, which is, in turn, a host for the object that does the real work: GoogleMap. So your first step is to acquire a reference to this master object. Do this by calling getMapAsync(OnMapReadyCallback).

Listing 32.12  Getting a GoogleMap (LocatrFragment.java)

p​u​b​l​i​c​ ​c​l​a​s​s​ ​L​o​c​a​t​r​F​r​a​g​m​e​n​t​ ​e​x​t​e​n​d​s​ ​S​u​p​p​o​r​t​M​a​p​F​r​a​g​m​e​n​t​ ​{​
 ​ ​ ​ ​p​r​i​v​a​t​e​ ​s​t​a​t​i​c​ ​f​i​n​a​l​ ​S​t​r​i​n​g​ ​T​A​G​ ​=​ ​"​L​o​c​a​t​r​F​r​a​g​m​e​n​t​"​;​

 ​ ​ ​ ​p​r​i​v​a​t​e​ ​G​o​o​g​l​e​A​p​i​C​l​i​e​n​t​ ​m​C​l​i​e​n​t​;​
 ​ ​ ​ ​p​r​i​v​a​t​e​ ​G​o​o​g​l​e​M​a​p​ ​m​M​a​p​;​ ​ ​ ​ ​p​r​i​v​a​t​e​ ​B​i​t​m​a​p​ ​m​M​a​p​I​m​a​g​e​;​ ​ ​ ​ ​p​r​i​v​a​t​e​ ...

Get Android Programming: The Big Nerd Ranch Guide, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.