有谁知道如何将默认摄像头位置设置为用户当前位置? 感谢。
let camera = GMSCameraPosition.camera(withLatitude: 56.8, longitude: 14.8, zoom: 13)
let mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
mapView.isMyLocationEnabled = true
答案 0 :(得分:0)
请尝试这些代码,它会帮助您
locationManager = [[CLLocationManager alloc] init];
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters;
[locationManager requestWhenInUseAuthorization];
[locationManager requestAlwaysAuthorization];
[locationManager startUpdatingLocation];
latitude = locationManager.location.coordinate.latitude;
longitude = locationManager.location.coordinate.longitude;
self.googleMapView.delegate = self;
GMSCameraPosition *sydney = [GMSCameraPosition cameraWithLatitude:latitude
longitude:longitude
zoom:10];
[_googleMapView animateToLocation:CLLocationCoordinate2DMake(longitude, longitude)];
[self.googleMapView setMyLocationEnabled:YES];
[_googleMapView setCamera:sydney];