lalala lalala - 1 month ago 8x
iOS Question

Google Map SDK, iOS , cannot get myLocation

I'd like to show my location on iOS app by using Google Maps SDK. However, it cannot get my location. I referred the following documents, document1, document2

This is my code. It only shows the map of United Kingdom.

Please help me to solve the problem.

import UIKit

class SearchVC: UIViewController,CLLocationManagerDelegate{

///Google Map
@IBOutlet weak var mapView:GMSMapView!
let locationManager = CLLocationManager()

override func viewDidLoad() {
locationManager.delegate = self


override func didReceiveMemoryWarning() {
// Dispose of any resources that can be recreated.

func locationManager(manager:CLLocationManager!, didChangeAuthorizationStatus status: CLAuthorizationStatus){
if status == .AuthorizedWhenInUse{


mapView.myLocationEnabled = true
mapView.settings.myLocationButton = true
func locationManager(manager:CLLocationManager!, didUpdateLocations locations:[AnyObject]!){
if let location = locations.first as? CLLocation{ = GMSCameraPosition(target:location.coordinate, zoom:15,bearing:0, viewingAngle:0)


Heres some code to parse your location... I think your just having an issue extracting the location info for the map view to load

func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) {
    CLGeocoder().reverseGeocodeLocation(manager.location, completionHandler: { (placemarks, error) -> Void in
    if (error != nil) {
        println("Error:" + error.localizedDescription)

    if placemarks.count > 0 {
        let pm = placemarks[0] as CLPlacemark
        pm.location.coordinate; = GMSCameraPosition(target:pm.location.coordinate, zoom:15,bearing:0, viewingAngle:0)

    }else {
        println("Error with data")

I haven't compiled this code and I'm not swift savvy but hopefully this helps

To change your location go to Edit Scheme... enter image description here

Then select whatever location you want to simulate enter image description here