How do I get the users location latitude and longitude?

对着背影说爱祢 提交于 2019-12-13 09:39:02

问题


I need to access the users location in this method contained in the mainViewController

-(void)loadAnnotations{
[mapView removeAnnotations:mapView.annotations];

CLLocationCoordinate2D workingCoordinate;
workingCoordinate.latitude= //here i need the users latitude
workingCoordinate.longitude= //here i need the users longitude
NSLog(@" this is %@", workingCoordinate.latitude);
iProspectLiteAnnotation *tempMine = [[iProspectLiteAnnotation alloc] initWithCoordinate:workingCoordinate];
[tempMine setTitle:@"Present Location"];
[tempMine setAnnotationType:iProspectLiteAnnotationTypeUser];
[mapView addAnnotation:tempMine];
}

however the mainViewController is already set to

<fipsideViewControllerDelegate>

What should I add to the header file and the implementation file to poll the location Manager for the users current latitude and longitude?


回答1:


In your other question I already told you how to get the location, so:

-[CLLocation coordinate]

It never hurts to look in the documentation before posting questions...



来源:https://stackoverflow.com/questions/3066036/how-do-i-get-the-users-location-latitude-and-longitude

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!