私の最後の既知の場所は更新されていませんが、googlemap.setMyLocationEnable(true)
私の場所は更新されています。誰でも助けることができますか?これが私のコードです:
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)));
}