我创建了一个MAPVIEW来获取用户当前位置的纬度和经度。
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
didUpdateLocations
委托方法给出一个具有当前位置纬度和经度的数组
如何从该阵列获得纬度和经度?
答案 0 :(得分:1)
委托方法将返回CLLocation
个对象的数组。此数组包含数组末尾的最新位置。
所以,你应该这样收到它:
CLLocation *loc = [locations lastObject];
要访问纬度,请在代码下面写经度。
CLLocationDegrees latitude = loc.coordinate.latitude;
CLLocationDegrees longitude = loc.coordinate.longitude;
答案 1 :(得分:1)
在locations
数组中,您将找到CLLocation对象。从那里,你可以得到这样的坐标:
CLLocation *location = [locations objectAtIndex:someIndex]; //You can have more than one update so loop through it.
CLLocationDegrees latitude = location.coordinate.latitude;
CLLocationDegrees longitude = location.coordinate.longitude;
答案 2 :(得分:0)
您需要实现以下委托方法以获取用户的当前位置。
(void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation {
}
答案 3 :(得分:0)
您需要从位置数组中获取最后一个对象,然后顺便抓住纬度和经度。
CLLocation *location = [locations lastObject];
CLLocationDegrees lattitude = location.coordinate.latitude;
CLLocationDegrees longitude = location.coordinate.longitude;
答案 4 :(得分:0)
import urllib.request
urls = ['foo.com/bar.gz', 'foobar.com/barfoo.gz', 'bar.com/foo.gz']
for u in urls:
urllib.request.urlretrieve(u)