2014-02-05 54 views
0

當我點擊我的位置按鈕時,如何放大並移動到當前位置?放大到當前位置android

我對這個下面的實現:

googleMap.setMyLocationEnabled(true); 

這顯示了按鈕,但是當我按下這個什麼也沒有發生。我怎樣才能移動到我目前的位置?

+0

http://stackoverflow.com/questions/18425141/android-google-maps-api-v2-zoom-to-current-location – Niko

+0

使用'googleMap.animateTo(mypoint_current loc); –

+0

我應該在哪裏打電話?在onCreate方法? – user2998771

回答

0

使用此

googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location.getLatitude(), location.getLongitude()), 8.0f)); 
0
googleMap.setMyLocationEnabled(true); 

只顯示你的位置。

使用此爲拉近到你的位置按鈕:

googleMap.getUiSettings().setMyLocationButtonEnabled(true); 


Here是一個不錯的教程。

+0

我在哪裏設置?如何檢測點擊我的位置按鈕? – user2998771

+0

您不必檢測按鈕是否被點擊。它是爲你完成的:http://developer.android.com/reference/com/google/android/gms/maps/UiSettings.html#setMyLocationButtonEnabled(boolean)在創建你的googleMap之後放置它。 – EarlOfEgo