I am working with Google Maps V2 and i want that the blue arrow is always centered on the map when i was driving/moving. But it remains for a 3-4 seconds on the spot and then jumps suddenly to the center. If i drive fast, the arrow is even in the few seconds out of the map and jumps then to the center. What i am doing wrong in the code?
public class MainActivity extends FragmentActivity implements LocationListener {
....
//when button is clicked
public void initStart() {
initMap();
initLocation();
}
public void initMap() {
supportmapfragment = (SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.googleMap);
myMap = supportmapfragment.getMap();
myMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
myMap.setMyLocationEnabled(true);
myMap.getUiSettings().setAllGesturesEnabled(false);
myMap.getUiSettings().setZoomControlsEnabled(false);
}
public void initLocation() {
lm = (LocationManager)getSystemService(LOCATION_SERVICE);
provider = LocationManager.GPS_PROVIDER;
Location location = lm.getLastKnownLocation(provider);
if(provider != null ) {
onLocationChanged(location);
}
lm.requestLocationUpdates(provider, 0, 0, this);
}
....
@Override
public void onLocationChanged(Location location) {
if(location != null) {
LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
myMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 17));
}
}
Does anyone have a counsel? thanks in advance
PS: sry for my english (its not good) :)