Ανάκτηση UserLocation συντεταγμένων με MapKit

ψήφοι
5

I m χρησιμοποιώντας MapKit στην αίτησή μου και disaply τη θέση του χρήστη με


[mapview setShowUserLocation:YES];

Θέλω να ρυθμίσετε το region.center.latitude και region.center.longitude με τη συντεταγμένη του userLocation, πώς να το κάνουμε;

Δημοσιεύθηκε 01/02/2010 στις 11:34
πηγή χρήστη
Σε άλλες γλώσσες...                            


5 απαντήσεις

ψήφοι
10

Εδώ είναι η απάντησή μου, προσπαθώ κάτι τέτοιο και εργασίας του:


//inside my ViewDidLOad
locManager = [[CLLocationManager alloc] init];
[locManager setDelegate:self];
[locManager setDesiredAccuracy:kCLLocationAccuracyBest];
[locManager startUpdatingLocation];

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation  {
CLLocationCoordinate2D loc = [newLocation coordinate]; [maptView setCenterCoordiante:loc]; }
Απαντήθηκε 10/03/2010 στις 11:43
πηγή χρήστη

ψήφοι
6

Πολύ ευκολότερο:

-(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation {
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(userLocation.location.coordinate, 1500, 1500);
[mapView setRegion:region animated:YES];
}
Απαντήθηκε 15/08/2012 στις 14:52
πηγή χρήστη

ψήφοι
2

Για κάποιο λόγο, αυτό δεν λειτούργησε για μένα. Είναι με τη λήψη των συντεταγμένων (0.0000, 0.0000). Παρακάτω είναι ο κωδικός μου, αν έχετε την ευκαιρία να το ελέγξουμε. Ευχαριστώ για τη βοήθεια!

[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];
Απαντήθηκε 20/12/2010 στις 09:47
πηγή χρήστη

ψήφοι
1

Νομίζω ότι αυτό απαντά στην ερώτησή σας: Επιστρέφοντας Mapkit Userlocation Συντεταγμένες

(χρησιμοποιεί το mapView.userLocation.location.coordinate.latitudeκαι mapView.userLocation.location.coordinate.longitude properties)

και στη συνέχεια έγχυση των εν λόγω συντεταγμένες σε η

-(void)setCenterCoordinate:(CLLocationCoordinate2D)coordinate animated:(BOOL)animated

της MKMapView περίπτωση σας.

Απαντήθηκε 01/02/2010 στις 11:41
πηγή χρήστη

ψήφοι
0

Χρησιμοποιώντας εκπρόσωπος:

  1. Προσθέστε Mapkit εκπρόσωπος: MKMapViewDelegate
  2. Μέθοδος Επίτευξη: MapView didUpdateUserLocation
    -(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation {
        MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(userLocation.location.coordinate,
            500, 500);
        [mapView setRegion:region animated:YES];
    }
    

Χωρίς εκπρόσωπος:

[self.mapView setuserTrackingMode:MKUserTrackingModeFollow];
Απαντήθηκε 23/05/2019 στις 04:03
πηγή χρήστη

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