내 마지막 위치는 업데이트되지 않지만 googlemap.setMyLocationEnable(true)
은 내 위치 정보를 업데이트하고 있습니다. 누구든지 도와 줄 수 있습니까? 여기 내 코드는 다음과 같습니다.Android Google지도 위치 업데이트 작업하지 않음
private void setUpMap() {
if(googlemap == null) {
googlemap = ((MapFragment)getFragmentManager().findFragmentById(R.id.map)).getMap();
if(googlemap != null) {
googlemap.setMyLocationEnabled(true);
LocationManager lm = (LocationManager) getSystemService(LOCATION_SERVICE);
String provider = lm.getBestProvider(new Criteria(), true);
if (provider == null){
onProviderDisabled(provider);
}
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
Location loc = lm.getLastKnownLocation(provider);
if (loc != null) {
onLocationChanged(loc);
}
googlemap.setOnMapLongClickListener(onLongClickMapSettings());
}
}
}
private OnMapLongClickListener onLongClickMapSettings() {
// TODO Auto-generated method stub
return new OnMapLongClickListener() {
@Override
public void onMapLongClick(LatLng arg0) {
// TODO Auto-generated method stub
Log.i(arg0.toString(), "User long clicked");
}
};
}
@Override
public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
LatLng latlng = new LatLng(location.getLatitude(), location.getLongitude());
googlemap.moveCamera(CameraUpdateFactory.newLatLng(latlng));
googlemap.animateCamera(CameraUpdateFactory.zoomTo(15));
Marker ME = googlemap.addMarker(new MarkerOptions()
.position(latlng)
.title("Current Location(You)")
.snippet("Current")
.icon(BitmapDescriptorFactory.fromResource(R.drawable.user_marker)));
}