UserLocation MapKit ile Koordinat Al

oy
5

Ben benim uygulamada MapKit kullanıyorum ve kullanıcı yerini disaply


[mapview setShowUserLocation:YES];

Ben userLocation koordinatı ile region.center.latitude ve region.center.longitude ayarlamak istediğiniz, nasıl yapılacağını?

Oluştur 01/02/2010 saat 11:34
kaynak kullanıcı
Diğer dillerde...                            


5 cevaplar

oy
10

İşte bu ve bunun çalışma gibi bir şey denemek, cevabım ise:


//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]; }
Cevap 10/03/2010 saat 11:43
kaynak kullanıcı

oy
6

Daha kolay:

-(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation {
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(userLocation.location.coordinate, 1500, 1500);
[mapView setRegion:region animated:YES];
}
Cevap 15/08/2012 saat 14:52
kaynak kullanıcı

oy
2

Nedense, bu benim için işe yaramadı. Bu koordinatlar (0.0000, 0.0000) götürüyor. Bunu kontrol etmek için bir şansı varsa Aşağıda benim kodudur. Yardım için teşekkürler!

[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];
Cevap 20/12/2010 saat 09:47
kaynak kullanıcı

oy
1

: Ben bu sorunuza yanıt düşünüyorum Mapkit Userlocation Koordinatları döndürme

(kullanır mapView.userLocation.location.coordinate.latitudeve mapView.userLocation.location.coordinate.longitude properties)

ve bu daha sonra bu koordinatları enjekte

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

senin MKMapView örneğinin.

Cevap 01/02/2010 saat 11:41
kaynak kullanıcı

oy
0

temsilci kullanarak:

  1. Mapkit temsilci ekleyin: MKMapViewDelegate
  2. yöntem elde: MapView didUpdateUserLocation
    -(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation {
        MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(userLocation.location.coordinate,
            500, 500);
        [mapView setRegion:region animated:YES];
    }
    

temsilci olmadan:

[self.mapView setuserTrackingMode:MKUserTrackingModeFollow];
Cevap 23/05/2019 saat 04:03
kaynak kullanıcı

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