繼上篇步驟完成後,已經可以看到地圖,只是位置並不是想像中是在目前裝置的位置,是因為沒有定位到目前裝置的位置,要定位的話則必需先取得目前位置的經緯度再告知Google Map,使它可以移動到該經緯度,步驟如下: 一、先產生定位相關元件: 先新增定位需要的權限 < uses-permission android:name = "android.permission.ACCESS_FINE_LOCATION" /> < uses-permission android:name = "android.permission.ACCESS_COARSE_LOCATION" /> < uses-permission android:name = "android.permission.INTERNET" /> 再產生相關元件 public static LocationManager lmgr ; //取得location service public static MyLocationListener mll ; //這是位罝改變時的監聽事件 二、取得location service之後並新增監聽事件和建立service: lmgr = ( LocationManager ) getSystemService ( LOCATION_SERVICE ) ; mll = new MyLocationListener () ; lmgr . requestLocationUpdates ( LocationManager . NETWORK_PROVIDER , 1100 , 0 , mll ) ; //上述是開啟網路定位服務 lmgr . requestLocationUpdates ( LocationManager . GPS_PROVIDER , 1100 , 0 , mll ) ; //上述是開啟gps定位服務 上述兩個方法所帶入的參數如下: 定位提供者: LocationManager . NETWORK_PROVIDER / LocationManag...