Načtení UserLocation souřadnic s MapKit

hlasů
5

I m pomocí MapKit v mé žádosti a disaply umístění uživatele s


[mapview setShowUserLocation:YES];

Chci nastavit region.center.latitude a region.center.longitude s souřadnici userLocation, jak na to?

Položena 01/02/2010 v 11:34
zdroj uživatelem
V jiných jazycích...                            


5 odpovědí

hlasů
10

Tady je moje odpověď, jsem zkusit něco takového a jeho práci:


//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]; }
Odpovězeno 10/03/2010 v 11:43
zdroj uživatelem

hlasů
6

Mnohem jednodušší:

-(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation {
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(userLocation.location.coordinate, 1500, 1500);
[mapView setRegion:region animated:YES];
}
Odpovězeno 15/08/2012 v 14:52
zdroj uživatelem

hlasů
2

Z nějakého důvodu, že to není práce pro mě. To mě brát na souřadnicích (0.0000, 0.0000). Níže je můj kód, pokud máte možnost podívat se na to. Děkuji 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];
Odpovězeno 20/12/2010 v 09:47
zdroj uživatelem

hlasů
1

Myslím, že toto odpovědělo na tvou otázku: Vracející Mapkit Userlocation Souřadnice

(používá mapView.userLocation.location.coordinate.latitudea mapView.userLocation.location.coordinate.longitude properties)

a pak aplikovat tyto souřadnice do

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

vaší instance MKMapView.

Odpovězeno 01/02/2010 v 11:41
zdroj uživatelem

hlasů
0

Používání delegáta:

  1. Přidejte Mapkit delegáta: MKMapViewDelegate
  2. metody dosáhnout: MapView didUpdateUserLocation
    -(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation {
        MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(userLocation.location.coordinate,
            500, 500);
        [mapView setRegion:region animated:YES];
    }
    

Bez delegáta:

[self.mapView setuserTrackingMode:MKUserTrackingModeFollow];
Odpovězeno 23/05/2019 v 04:03
zdroj uživatelem

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