Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wrong Location - located in San Francisco and not in France

I am in France, and when I try my new func locationManager function, my map view locate me in San Francisco. Any idea?

override func viewDidLoad() {
    super.viewDidLoad()   

    if (CLLocationManager.locationServicesEnabled())
    {
        locationManager = CLLocationManager()
        locationManager.delegate = self
        locationManager.desiredAccuracy = kCLLocationAccuracyBest
        locationManager.distanceFilter = kCLDistanceFilterNone
        locationManager.requestAlwaysAuthorization()
        locationManager.startUpdatingLocation()
    }
}

func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) {
    let location = locations[locations.count-1] as CLLocation

    let center = CLLocationCoordinate2D(latitude: location.coordinate.latitude, longitude: location.coordinate.longitude)
    let region = MKCoordinateRegion(center: center, span: MKCoordinateSpan(latitudeDelta: 0.01, longitudeDelta: 0.01))

    self.map.setRegion(region, animated: true)
}

I am using the simulator.

like image 906
PMIW Avatar asked Aug 23 '14 09:08

PMIW


1 Answers

The iOS Simulator defaults to US - San Fran, and does not give you an estimate of your Mac's actual location.

However you can simulate movement or even a specific location like so:

Under the Debug menu in the Simulator, the last entry is "Location"; this gives you a sub menu with:

  • None
  • Custom Location
  • Apple Stores
  • Apple
  • City Bicycle Ride
  • City Run
  • Freeway Drive
  • Custom Location lets you enter a Lat/Long value.

Bicycle ride, City Run, and Freeway Drive are simulation of a moving location (in Cupertino, of course).

like image 114
Woodstock Avatar answered Sep 20 '22 19:09

Woodstock