ios - GMSMapView sdk中是否有显示当前位置的默认按钮

标签 ios google-maps

我正在添加自定义按钮并添加操作

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

用于将 map 移动到当前位置。sdk中是否有默认按钮?

最佳答案

是的,有一个默认按钮来显示 map 的当前位置。只有当您在 API 中设置 myLocationEnable 时,它才会可见。

来自文档

Google Map SDK for iOS

By default, no location data is shown on the map. You may enable the blue "My Location" dot and compass direction by setting myLocationEnabled on GMSMapView.

mapView_.myLocationEnabled = YES;

Enabling this feature will also provide the user's current location through the myLocation property. This property may not be immediately available - for example, if the user is prompted by iOS to allow access to this data. It will be nil in this case.

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

关于ios - GMSMapView sdk中是否有显示当前位置的默认按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26751376/

相关文章:

javascript - 可以使用 Node.js 通过 Google API 在 map 上进行真正的实时更新

ios - UIImagepicker 显示图像捕获而不是视频录制

objective-c - iOS 检测购买的版本以更改功能

javascript - 在整个谷歌地图上放置透明叠加层(就像模态封面)

android - 尝试从纬度和经度坐标设置 map 时位置显示不正确

android.view.InflateException : Binary XML file line #20: Error inflating class fragment

iphone - 仅当用户下拉表格时才显示搜索栏

ios - UISearchDisplayController - 如何预加载 searchResultTableView

objective-c - NSInvocation:无法识别的选择器,尽管已设置

ios - 当用户在路线上移动时刷新用户当前位置