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;
{
CLL开发者_运维问答ocationCoordinate2D theCoordinate;
theCoordinate.latitude =MKUserLocation.latitude; //37.786996;// Here we have to change the with current location
theCoordinate.longitude = MKUserLocation.longitude;
return theCoordinate;
}
Make use of CLLocationManagerDelegate
method
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
[map setShowsUserLocation:TRUE];
map is the object of MKMapView.
Use this delegate method
-(void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation {
if (userLocation_) {
[userLocation_ release];
}
userLocation_ = [newLocation retain];
}
精彩评论