跟踪谷歌地图上的用户位置
我有谷歌地图sdk在iOS和启用userlocation =是。 我想在移动时通过GPS获取用户位置。 在用户不断移动的情况下,我无法在文档中find任何返回位置更新的方法。 我想保持我的用户在屏幕中心不断更新相机使用这些位置。
这个有什么意思? 有一个方法didchangecameraposition更新时,我在地图上应用手势,但不是当GPS更新。
您无法完全使用Google地图SDK,您必须使用CLLocationManger框架来获取位置更新。
初始化您的locationManager以注册重大位置更改并正确设置代理
if (nil == locationManager) locationManager = [[CLLocationManager alloc] init]; locationManager.delegate = self; //Configure Accuracy depending on your needs, default is kCLLocationAccuracyBest locationManager.desiredAccuracy = kCLLocationAccuracyKilometer; // Set a movement threshold for new events. locationManager.distanceFilter = 500; // meters, set according to the required value. [locationManager startUpdatingLocation];
位置pipe理员的代表:
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations { // If it's a relatively recent event, turn off updates to save power. CLLocation* location = [locations lastObject]; NSDate* eventDate = location.timestamp; NSTimeInterval howRecent = [eventDate timeIntervalSinceNow]; if (abs(howRecent) < 15.0) { // Update your marker on your map using location.coordinate by using the GMSCameraUpdate object GMSCameraUpdate *locationUpdate = [GMSCameraUpdate setTarget:location.coordinate zoom:YOUR_ZOOM_LEVEL]; [mapView_ animateWithCameraUpdate:locationUpdate]; }
- 我如何从我的原生应用程序中启动Google Maps iPhone应用程序?
- 使用其他旅行模式的Google地图方向XML或JSON
- 在Google地图上为ios添加自定义标记上的文字
- iOS GoogleMaps SDK错误:“:无法识别的select器发送”
- iOS打开地图应用程序的链接
- 适用于iOS的Google Maps API myLocationEnabled无效
- 在Google Maps for iOS上路线图不要按照街道线路进行
- Google Maps for iOS – 如何判断一个标记是否在屏幕的边界内?
- 当使用GoogleMaps时,myLocationEnabled在swift上更改为isMyLocationEnabled