Note that there are some explanatory texts on larger screens.

plurals
  1. POGet _correct_ coordinates of user MapKit on simulator
    primarykey
    data
    text
    <p>the situation is following, i am running xCode 4.1 on MacOS 10.7, starting iPhone simulator and using MapKit am trying to get <strong>REAL</strong> user's coordinates ... default user's location is in Cupertino, USA ... to get cordinates of this point i use :</p> <pre><code>self.mapView.userLocation.location.coordinate </code></pre> <p>... but this gets me to the center of the map (in Africa) ... </p> <p><strong>Question #1 :</strong> Why??? Why user's pin is set to Cupertino but its coordinates are (lat:0, lon:0) in Africa?</p> <p>... then ... </p> <p>I have setup my controller as CCLocationManagerDelegate and MKMapViewdelegate and initialized controller as delegate for CCLocationManagerDelegate's events ... but neither of these delegate methods was called ... </p> <pre><code>- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id&lt;MKAnnotation&gt;)annotation - (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation </code></pre> <p><strong>Question #2 :</strong> Why delegate methods are not triggered even once?</p> <p>My controller : </p> <pre><code>//@interface MapController : UIViewController&lt;CLLocationManagerDelegate, MKMapViewDelegate&gt; //@property (nonatomic, retain) MapModel *mapModel; //@property (nonatomic, retain) IBOutlet MKMapView *mapView; - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { ... } - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id&lt;MKAnnotation&gt;)annotation { ... } - (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation { ... } - (void)viewDidLoad { [super viewDidLoad]; self.mapModel = [[[MapModel alloc] init:self] autorelease]; [self.mapView setShowsUserLocation:YES]; [self.mapView setZoomEnabled:YES]; [self.mapView setScrollEnabled:YES]; [self.mapView setMapType:MKMapTypeStandard]; CLLocationCoordinate2D x = self.mapView.userLocation.location.coordinate; // (0,0) why??? //[self.mapView setRegion:xx animated:YES]; //[self.mapView regionThatFits:self.mapModel.region]; [[self.mapView userLocation] setCoordinate:[x coordinate]]; } ... </code></pre> <p>And model :</p> <pre><code> //@property (nonatomic, copy) NSString *user; //@property (nonatomic, copy) NSString *caption; //@property (nonatomic, copy) NSString *description; //@property (nonatomic, assign) MKCoordinateRegion region; //@property (nonatomic, retain) CLLocationManager *manager; - (id)init :(id)delegate { self.manager = [[[CLLocationManager alloc] init] autorelease]; self.manager.delegate = delegate; self.manager.distanceFilter = kCLDistanceFilterNone; self.manager.desiredAccuracy = kCLLocationAccuracyHundredMeters; [self.manager startUpdatingLocation]; MKCoordinateRegion region = {{0, 0}, {0.2, 0.2}}; self.region = region; return self; } </code></pre> <p>Thanks, Art</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload