2013-08-18 42 views

回答

0

setMyLocationEnable不會單獨工作。你必須在onResume中放置requestLocationUpdates。

 @Override 
    public void onResume() { 
    super.onResume(); 
    if (isGPSEnabled) { 
     locMgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, time, distance, this); 
     } 
     if (isNetworkEnabled) { 
      locMgr.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, time, distance, this); 
     } 

    map.setLocationSource(this); 

    } 
0

首先,您應該聲明一個匿名內部類,實現Google.OnMyLocationChangeListener,或者你可以只實現它在你的主類。假設您的地圖實例被稱爲map。您將必須設置監聽器,如下所示:map.setOnMyLocationChangeListener(this)。然後,你將不得不這樣做:

@Override 
public void onMyLocationChange(Location location) //inherited from the interface you implemented 
{ 
//do your thing, the variable "location" holds everything you need 
}