2

I am using google map sdk version 1.9.1.

I want to display map with current location .

here is my code.

@interface ViewController ()
 {
    GMSMapView *mapView_;
 }

- (void)viewDidLoad {
[super viewDidLoad];
mapView_ = [GMSMapView mapWithFrame:CGRectMake(0.0f, 100.0f, 320.0f, 300.0f) camera:nil];
mapView_.myLocationEnabled = YES;
[self.view addSubview: mapView_];
}

but I can't display current location. appreciate for help.

Vinod Jadhav
  • 1,055
  • 1
  • 15
  • 37
  • see this link http://stackoverflow.com/questions/17366403/gmsmapview-mylocation-not-giving-actual-location – Anbu.Karthik Jun 01 '15 at 07:33
  • Make sure your app accessing device's location: http://stackoverflow.com/questions/24062509/location-services-not-working-in-ios-8. Try to set _yourMapView.settings.myLocationButton = YES and tap on this button? – phuongle Jun 01 '15 at 07:49
  • I got location but it gives me wrong location. it returns location of "san Francisco" @phuongle – Vinod Jadhav Jun 01 '15 at 08:22
  • Let try other solution, listen Apple location by CLLocationManager:didUpdateLocations method. And then call [_mapView animateToLocation:CLLocationCoordinate2DMake(CLLocationDegrees latitude, CLLocationDegrees longitude)] to update current location in Google Map. – phuongle Jun 01 '15 at 08:37
  • In DidUpdate location I got wrong location when I updated ios 8.3 @phuongle – Vinod Jadhav Jun 01 '15 at 08:41

2 Answers2

0

You must set your location in

Debug>Location>custom lacation

Like

enter image description here

If you can test in device then enable your location in setting screen

Lalji
  • 695
  • 1
  • 6
  • 19
0
  1. First your app has to ask permission for accessing user location in ios8. See this post: Location Services not working in iOS 8 or this: iOS: App is not asking user's permission while installing the app. getting kCLAuthorizationStatusNotDetermined every time - Objective-c & Swift

  2. After that you call the location manager's [locationManager startUpdatingLocation] method.

Then you will see your current updated location.

Community
  • 1
  • 1
Kiran Thapa
  • 1,230
  • 2
  • 13
  • 28