Let's talk about the map V2 API key first:
During app packaging, You need to generate a XXX. keystore and use the sha1 generated by this secret room library to apply for the key as the key in androidmanifest. xml.
(Sometimes the key generated using Debug. keystore can also be used for unknown reasons)
Enter the subject:
According to https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/CameraUpdateFactory? Hl = ZH-CN description,
Cameraupdatefactorypublic final class
Cameraupdatefactory
A class containing methods for creatingCameraUpdateObjects
That change a map's camera. to modify the map's camera, callanimateCamera(CameraUpdate),animateCamera(CameraUpdate,
GoogleMap.CancelableCallback)OrmoveCamera(CameraUpdate),
UsingCameraUpdateObject
Created with this class.
For example, to zoom in on a map, you can use the following code:
GoogleMap map = ...; map.animateCamera(CameraUpdateFactory.zoomIn());
Prior to using any methods from this class, you must do one of the following to ensure that this class is initialized:
- Wait for
GoogleMapTo
Become available fromMapFragmentOrMapViewThat
You have added to your application. You can verify thatGoogleMapIs
Available by callinggetMap()Method and checking that the returned object is
Not null.
- Call
initialize(Context).
As long as a com. Google. Android. GMS. Common. googleplayservicesnotavailableexception isn' t thrown, this class will be correctly initialized.
That is, initializationCameraupdatefactoryNeed to ensure
1. The GoogleMap object is not empty.
2. initialize mapsinitializer. initialize (context ).
Therefore, if the GoogleMap object is excluded as null, you only need to call mapsinitializer. initialize (context) before cameraupdatefactory to initialize the object.