@@ -52,7 +52,7 @@ public class PrivyMapsFragment extends Fragment implements OnMapReadyCallback, G
5252 private LocationRequest mLocationRequest ;
5353 private static int UPDATE_INTERVAL = 10000 ; // 10 sec
5454 private static int FATEST_INTERVAL = 5000 ; // 5 sec
55- private static int DISPLACEMENT = 10 ; // 10 meters
55+ private static int DISPLACEMENT = 50 ; // 50 meters
5656
5757 // My location
5858 private Location myLocationData ;
@@ -156,10 +156,14 @@ private void getMyCurrentLocation() {
156156 myLocationData = getCurrentLocation ();
157157 if (myLocationData != null ) {
158158
159+ float bearing = 0 ;
160+ if (myLocationData .hasBearing ())
161+ bearing = myLocationData .getBearing ();
162+
159163 MY_LOCATION_CAMERA_POS = new CameraPosition .Builder ()
160164 .target (new LatLng (myLocationData .getLatitude (), myLocationData .getLongitude ()))
161165 .zoom (15.0f )
162- .bearing (0 )
166+ .bearing (bearing )
163167 .tilt (25 )
164168 .build ();
165169
@@ -270,7 +274,7 @@ protected void createLocationRequest() {
270274 mLocationRequest .setInterval (UPDATE_INTERVAL );
271275 mLocationRequest .setFastestInterval (FATEST_INTERVAL );
272276 mLocationRequest .setPriority (LocationRequest .PRIORITY_HIGH_ACCURACY );
273- mLocationRequest .setSmallestDisplacement (DISPLACEMENT ); // 10 meters
277+ mLocationRequest .setSmallestDisplacement (DISPLACEMENT ); // 50 meters
274278 }
275279
276280 private void startLocationUpdates () {
@@ -286,6 +290,7 @@ private void stopLocationUpdates() {
286290
287291 @ Override
288292 public void onLocationChanged (Location location ) {
293+ myLocationData = location ;
289294 getMyCurrentLocation ();
290295 }
291296
0 commit comments