Wiederkehrende MapKit Userlocation Koordinaten

stimmen
1

wenn ich versuche, die lat / long Koordinaten für meinen aktuellen Standort zurückzukehren, meine Anwendung abstürzt ohne Erklärung des Fehlers ...

NSLog(@%@, mapView.userLocation.location.coordinate);

Ich warte, bis das Telefon als auch den Standort findet ...

Veröffentlicht am 30/10/2009 um 21:58
quelle vom benutzer
In anderen Sprachen...                            


2 antworten

stimmen
5

mapView.userLocation.location.coordinateist eine Struktur , während die %@Formatangabe ein Objekt erwartet. Das wird funktionieren:

NSLog(@"%f, %f", mapView.userLocation.location.coordinate.latitude,
                 mapView.userLocation.location.coordinate.longitude);
Beantwortet am 30/10/2009 um 22:02
quelle vom benutzer

stimmen
0

Aus irgendeinem Grund, dies für mich nicht funktioniert hat. Es nimmt mich auf die Koordinaten (0.0000, 0.0000). Unten ist mein Code, wenn Sie eine Chance zu überprüfen, es haben wird. Danke für die Hilfe!

[mapView setMapType:MKMapTypeStandard];
    [mapView setZoomEnabled:YES];
    [mapView setScrollEnabled:YES];
    mapView.showsUserLocation=TRUE;

    MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } };

    CLLocationCoordinate2D myCoord = {mapView.userLocation.location.coordinate.latitude,mapView.userLocation.location.coordinate.longitude};
    [mapView setCenterCoordinate:myCoord animated:YES];

    region.span.longitudeDelta = 0.01f;
    region.span.latitudeDelta = 0.01f;
    [mapView setRegion:region animated:YES]; 

    [mapView setDelegate:self];
Beantwortet am 20/12/2010 um 23:57
quelle vom benutzer

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more