我正在使用 Google Maps V2,我希望蓝色箭头在我开车/移动时始终位于地图的中心。但它在原地停留了3-4秒,然后突然跳到中心。如果我开得快,箭头甚至会在地图之外的几秒钟内跳出然后跳到中心。我在代码中做错了什么?
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));
}
}
有人有建议吗?提前致谢
PS:对不起我的英语(不好):)