1

I'm using this code:

setMyLocationEnabled(true)

in order for google to detect my location, however it is extremely unresponsive and updates every 5-10 seconds - this is pretty slow especially in the car.

Do I have to set some criteria in order to fix this? Should I set up my own location manager? If so, can you please guide me through tutorials and code snippets?

Thanks.

J.Tey
  • 225
  • 4
  • 18

1 Answers1

1

You can change the location provider for the My location layer using the method map.setLocationSource(). That's the only tweak (besides enabling and disabling it) that you can do to the My Location layer.

You can find a working example using the Fused Location Provider here: Android: Google Maps location with low battery usage

Another option could be to replace the My Location layer with your own marker for better control on the layer as explained here: Google Maps: Current Location Marker (Period updates for GMaps)

Community
  • 1
  • 1
antonio
  • 18,044
  • 4
  • 45
  • 61
  • will map.setLocationSource() solve the issue of it being slow and unresponsive? – J.Tey Jul 28 '16 at 09:25
  • It depends on the refresh rate of the location source that you choose. For example if you use the Fused Location provider and it receives GPS updates each second (it can vary between devices), your My Location layer will update each second. – antonio Jul 28 '16 at 09:29
  • how would i adjust the refresh rate? – J.Tey Jul 28 '16 at 09:44
  • You can set the `minTime` parameter of the `requestLocationUpdates` method https://developer.android.com/reference/android/location/LocationManager.html#requestLocationUpdates(java.lang.String,%20long,%20float,%20android.location.LocationListener) but it sets the min update time, not the max update time. If your device cannot give positions at a faster rate there is nothing you can do about it... – antonio Jul 28 '16 at 09:52