2014-11-05 47 views
3

我增加了自定義按鈕,添加在SDK中的地圖移動到當前location.Is有一個默認的按鈕的動作是否有顯示當前位置在GMSMapView中SDK

CLLocationCoordinate2D target=CLLocationCoordinate2DMake(currentLocation.coordinate.latitude,currentLocation.coordinate.longitude); 
    [mapView_ animateToLocation:target]; 

一個默認按鈕?

回答

4

是的,有一個默認按鈕來顯示當前的地圖位置。只有在API中設置myLocationEnable時纔會顯示。

從文檔

Google Map SDK for iOS

缺省情況下,沒有位置數據被示出在地圖上。您可以通過在GMSMapView上設置myLocationEnabled來啓用藍色的「我的位置」點和指南針方向。

mapView_.myLocationEnabled = YES; 

啓用此功能也將通過myLocation財產提供用戶的當前位置。該屬性可能不會立即可用 - 例如,如果iOS提示用戶允許訪問此數據。在這種情況下它將是零。

NSLog(@"User's location: %@", mapView_.myLocation); 
+6

可能也需要這樣做: mapView.settings.myLocationButton =真 – Cymric 2015-05-06 10:23:01

相關問題