简体   繁体   中英

finding current location in iphone

trying add annotation on current location when ever i want Any number of annotation at the but it work can any help me out i try this code

 - (CLLocationCoordinate2D)coordinate;
{
    CLLocationCoordinate2D theCoordinate;
    theCoordinate.latitude =MKUserLocation.latitude;          //37.786996;// Here we have to change the with current location  
    theCoordinate.longitude = MKUserLocation.longitude;
    return theCoordinate; 
}

使用CLLocationManagerDelegate方法

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
[map setShowsUserLocation:TRUE];

map是MKMapView的对象。

Use this delegate method

-(void)locationManager:(CLLocationManager *)manager
        didUpdateToLocation:(CLLocation *)newLocation
               fromLocation:(CLLocation *)oldLocation {

        if (userLocation_) {
            [userLocation_ release];
        }
        userLocation_ = [newLocation retain];
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM