how to get current location in google map sdk in iphone
google-maps, google-maps-sdk-ios, iphone
Solution
Try this:
@property (nonatomic, retain) IBOutlet GMSMapView *googleMapView;
@property (nonatomic, retain) CLLocationManager *locationManager;
- (void)showCurrentLocation {
_googleMapView.myLocationEnabled = YES;
[self.locationManager startUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:newLocation.coordinate.latitude
longitude:newLocation.coordinate.longitude
zoom:17.0];
[_googleMapView animateToCameraPosition:camera];
//...
}
Problem
I want to set camera on current location and zoom level upto 10. So I have written code like this and for current location i get hint from this post. How to use delegates in Google map API for IOS 6 here is my code ``` mapView_=[[GMSMapView alloc]initWithFrame:CGRectZero]; CLLocationCoordinate2D currentPosition = mapView_.myLocation.coordinate; GMSCameraPosition* camera = [GMSCameraPosition cameraWithTarget: currentPosition zoom: 10]; mapView_.camera = camera; mapView_.delegate=self; mapView_.mapType = kGMSTypeSatellite; mapView_.myLocationEnabled = YES; self.view = mapView_; mapView_.settings.myLocationButton = YES; ``` But coordinate is 0.00 in device. Please Any Can help to solve out this issue?