Odzyskaj UserLocation współrzędnych z MapKit

głosy
5

I m za pomocą MapKit w mojej aplikacji i disaply lokalizację użytkownika z


[mapview setShowUserLocation:YES];

Chcę ustawić region.center.latitude i region.center.longitude z współrzędna userLocation, jak to zrobić?

Utwórz 01/02/2010 o 11:34
źródło użytkownik
W innych językach...                            


5 odpowiedzi

głosy
10

Oto moja odpowiedź, spróbuję coś takiego i jego pracy:


//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]; }
Odpowiedział 10/03/2010 o 11:43
źródło użytkownik

głosy
6

Dużo łatwiej:

-(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation {
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(userLocation.location.coordinate, 1500, 1500);
[mapView setRegion:region animated:YES];
}
Odpowiedział 15/08/2012 o 14:52
źródło użytkownik

głosy
2

Z jakiegoś powodu, to nie dla mnie. To zabiera mnie do współrzędnych (0,0000, 0,0000). Poniżej jest kod, jeśli masz szansę to sprawdzić. Dzięki za pomoc!

[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];
Odpowiedział 20/12/2010 o 09:47
źródło użytkownik

głosy
1

Myślę, że odpowiedzi na swoje pytanie: Wracając Mapkit Userlocation współrzędnych

(używa mapView.userLocation.location.coordinate.latitudea mapView.userLocation.location.coordinate.longitude properties)

a następnie zastosować te współrzędnych do

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

z wystąpieniem MKMapView.

Odpowiedział 01/02/2010 o 11:41
źródło użytkownik

głosy
0

Korzystanie delegata:

  1. Dodaj Mapkit delegata: MKMapViewDelegate
  2. Osiągnąć metodę: MapView didUpdateUserLocation
    -(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation {
        MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(userLocation.location.coordinate,
            500, 500);
        [mapView setRegion:region animated:YES];
    }
    

Bez delegata:

[self.mapView setuserTrackingMode:MKUserTrackingModeFollow];
Odpowiedział 23/05/2019 o 04:03
źródło użytkownik

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