@@ -52,7 +52,7 @@ public class PrivyMapsFragment extends Fragment implements OnMapReadyCallback, G
52
52
private LocationRequest mLocationRequest ;
53
53
private static int UPDATE_INTERVAL = 10000 ; // 10 sec
54
54
private static int FATEST_INTERVAL = 5000 ; // 5 sec
55
- private static int DISPLACEMENT = 10 ; // 10 meters
55
+ private static int DISPLACEMENT = 50 ; // 50 meters
56
56
57
57
// My location
58
58
private Location myLocationData ;
@@ -156,10 +156,14 @@ private void getMyCurrentLocation() {
156
156
myLocationData = getCurrentLocation ();
157
157
if (myLocationData != null ) {
158
158
159
+ float bearing = 0 ;
160
+ if (myLocationData .hasBearing ())
161
+ bearing = myLocationData .getBearing ();
162
+
159
163
MY_LOCATION_CAMERA_POS = new CameraPosition .Builder ()
160
164
.target (new LatLng (myLocationData .getLatitude (), myLocationData .getLongitude ()))
161
165
.zoom (15.0f )
162
- .bearing (0 )
166
+ .bearing (bearing )
163
167
.tilt (25 )
164
168
.build ();
165
169
@@ -270,7 +274,7 @@ protected void createLocationRequest() {
270
274
mLocationRequest .setInterval (UPDATE_INTERVAL );
271
275
mLocationRequest .setFastestInterval (FATEST_INTERVAL );
272
276
mLocationRequest .setPriority (LocationRequest .PRIORITY_HIGH_ACCURACY );
273
- mLocationRequest .setSmallestDisplacement (DISPLACEMENT ); // 10 meters
277
+ mLocationRequest .setSmallestDisplacement (DISPLACEMENT ); // 50 meters
274
278
}
275
279
276
280
private void startLocationUpdates () {
@@ -286,6 +290,7 @@ private void stopLocationUpdates() {
286
290
287
291
@ Override
288
292
public void onLocationChanged (Location location ) {
293
+ myLocationData = location ;
289
294
getMyCurrentLocation ();
290
295
}
291
296
0 commit comments