Lekérése UserLocation Egyeztess MapKit

szavazat
5

I használom MapKit én kérelmet és disaply a felhasználó helyen


[mapview setShowUserLocation:YES];

Szeretném beállítani a region.center.latitude és region.center.longitude a koordinátája userLocation, hogyan kell csinálni?

A kérdést 01/02/2010 11:34
a forrás felhasználó
Más nyelveken...                            


5 válasz

szavazat
10

Itt van a válasz, megpróbálom valami ilyesmi, és a működését:


//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]; }
Válaszolt 10/03/2010 11:43
a forrás felhasználó

szavazat
6

Sokkal könnyebb:

-(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation {
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(userLocation.location.coordinate, 1500, 1500);
[mapView setRegion:region animated:YES];
}
Válaszolt 15/08/2012 14:52
a forrás felhasználó

szavazat
2

Valamilyen oknál fogva ez nem működik nekem. Ez elvisz a koordinátákat (0,0000, 0,0000). Az alábbiakban a kód, ha van egy esélyt, hogy nézd meg. Köszönöm a segítséget!

[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];
Válaszolt 20/12/2010 09:47
a forrás felhasználó

szavazat
1

Azt hiszem, ez megválaszolja a kérdését: Visszatérve Mapkit Userlocation koordinátái

(használja a mapView.userLocation.location.coordinate.latitudeés mapView.userLocation.location.coordinate.longitude properties)

majd adja ezeket a koordinátákat a

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

a MKMapView fokon.

Válaszolt 01/02/2010 11:41
a forrás felhasználó

szavazat
0

Használata küldött:

  1. Add Mapkit küldött: MKMapViewDelegate
  2. Elérése módszer: MapView didUpdateUserLocation
    -(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation {
        MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(userLocation.location.coordinate,
            500, 500);
        [mapView setRegion:region animated:YES];
    }
    

Anélkül küldött:

[self.mapView setuserTrackingMode:MKUserTrackingModeFollow];
Válaszolt 23/05/2019 04:03
a forrás felhasználó

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