我正在研究一个iPhone应用程序,我想查找任何地方的经度,纬度和时区的详细信息。如何找到任何地方的纬度经度和时区?
我怎样才能一次获得所有这些细节?
我们可以很容易找到经纬度,但我们怎么才能得到那个地方的确切时区?
请问有谁能指导我?
谢谢。
我正在研究一个iPhone应用程序,我想查找任何地方的经度,纬度和时区的详细信息。如何找到任何地方的纬度经度和时区?
我怎样才能一次获得所有这些细节?
我们可以很容易找到经纬度,但我们怎么才能得到那个地方的确切时区?
请问有谁能指导我?
谢谢。
您可以通过使用
NSTimeZone* destinationTimeZone = [NSTimeZone systemTimeZone];
你是从CLLocationManager GET位置,你也来看看Geonames.org
这是一个免费的web服务,让您从任何设备获取时区获取很多来自long/lat的信息
它们还为GeoNames Webservices库提供免费(和开源)Java客户端(其他语言的库也提供:红宝石,蟒蛇,perl的,口齿不清......)
这里的一些信息,你可以从长期获取/纬度:(complete list of webservices here)
查找最近的地址
查找最近的路口
查找附近的街道
海拔时区
如果你想知道在这种情况下使用api你可以使用这个api bu t在这个api中,首先使用CLLocationManager
类找到你的经纬度,然后放入这个api。
http://ws.geonames.org/timezone?lat=# {}纬度LNG & =#{} LNG
而且读谷歌文档的多个API .....
https://developers.google.com/maps/documentation/timezone/
我希望它可以帮助你
它看起来像你想这样: -
NSString *timeZoneName = [[NSTimeZone localTimeZone] name];
对我而言,返回"Asia/Kolkata"
。
如果您使用的是systemTimeZone
那么它代表系统(设备)本身使用的时区。 localTimeZone
返回一个对象,该对象表示应用程序的当前默认时区。
使用此API获取数据并传递纬度和长度值。
可以使用CoreLocation得到经度和纬度。
在您希望经纬度的.h类中添加此项。
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
@interface CoreLocationViewController : UIViewController <CLLocationManagerDelegate> {
CLLocationManager *locationManager;
}
@property (retain, nonatomic) CLLocationManager *locationManager;
@end
而在你的.m文件
#import "CoreLocationViewController.h"
@implementation CoreLocationViewController
@synthesize locationManager;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
[self setLocationManager:[[CLLocationManager alloc] init]];
[locationManager setDelegate:self];
[locationManager setDistanceFilter:kCLDistanceFilterNone];
[locationManager setDesiredAccuracy:kCLLocationAccuracyHundredMeters];
[locationManager startUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
NSLog(@"My Latitude %f",newLocation.coordinate.latitude);
NSLog(@"My Latitude %f",newLocation.coordinate.longitude);
}
和当前时区您可以使用
NSTimeZone* currentTimeZone = [NSTimeZone systemTimeZone];
NSDateFormatter *dateFormatter = [dateFormat setTimeZone:currentTimeZone];
NSDate *rightNow = [NSDate date];
NSString *dateString = [dateFormatter stringFromDate:rightNow];
Z:我想罚款世界上任何地方的时区而不是当前时区。或至少是世界上任何地点的时区名称。有什么方法可以找到? – 2013-05-13 07:30:23
老兄当你的应用程序运行时,可以说伦敦,英格兰,然后它会给这个特定地点的时区。 – 2013-05-13 07:35:23
或者是你想制作一些他们在世界时钟中使用的时区查找器?像这个http://www.timeanddate.com/time/map/ – 2013-05-13 07:36:41
从CLLocation获取NSTimeZone:https://github.com/Alterplay/APTimeZones该实用程序的工作原理本地设备上没有3D派对服务。
或者如果你只想显示时区名称'[destinationTimeZone name]' – 2013-05-13 06:38:19
是啊。但我怎样才能得到世界上任何地方的时区。 – 2013-05-13 06:40:48
好的,如果你有这个用途,那么你需要使用一些网络服务。看看这个http://stackoverflow.com/questions/41504/timezone-lookup-from-latitude-longitude – 2013-05-13 06:43:10