我正在獲取設備的當前態度和經度並用nslog打印它,但現在如何在地圖上更新這些經度和緯度。這裏是我的代碼,請看看這個。如何使用google map api獲取iOS中的當前位置?
- (void)viewDidLoad {
[super viewDidLoad];
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.868
longitude:151.2086
zoom:12];
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
mapView_.settings.myLocationButton = YES;
self.view = mapView_;
mapView_.settings.compassButton = YES;
[self startStandardUpdates];
}
- (void)startStandardUpdates
{
// Create the location manager if this object does not
// already have one.
NSLog(@"startupdatelocation");
if (nil == _locationManager)
_locationManager = [[CLLocationManager alloc] init];
_locationManager.delegate = self;
_locationManager.desiredAccuracy = kCLLocationAccuracyKilometer;
// Set a movement threshold for new events.
_locationManager.distanceFilter = 10; // meters
[self.locationManager startUpdatingLocation];
}
- (void)startSignificantChangeUpdates
{
// Create the location manager if this object does not
// already have one.
if (nil == _locationManager)
_locationManager = [[CLLocationManager alloc] init];
_locationManager.delegate = self;
[self.locationManager startMonitoringSignificantLocationChanges];
}
- (void)locationManager:(CLLocationManager *)manager
didUpdateLocations:(NSArray *)locations {
// If it's a relatively recent event, turn off updates to save power.
CLLocation* location = [locations lastObject];
NSLog(@"location %@", location);
NSDate* eventDate = location.timestamp;
NSTimeInterval howRecent = [eventDate timeIntervalSinceNow];
if (abs(howRecent) < 15.0) {
// If the event is recent, do something with it.
NSLog(@"latitude %+.6f, longitude %+.6f\n",location.coordinate.latitude,
location.coordinate.longitude);
}
}
我正在打印當前的經緯度現在我怎麼會在地圖上顯示該位置也請幫我在這種情況下。
您添加的靜止座標的理由** cameraWithLatitude:-33.868 經度:151.2086 ** –
好吧,先生,但是當我刪除這行代碼什麼都沒有出現在視圖 –
我已經導入corelocation框架,但它不工作 –